Conditionally Processing Observations from Multiple SAS Data Sets |
The following program creates two SAS data sets, SOUTHAMERICAN and EUROPEAN. Each data set contains the following variables:
data southamerican; title "South American World Cup Finalists from 1954 to 1998"; input Year $ Country $ 9-23 Score $ 25-28 Result $ 32-36; datalines; 1998 Brazil 0-3 lost 1994 Brazil 3-2 won 1990 Argentina 0-1 lost 1986 Argentina 3-2 won 1978 Argentina 3-1 won 1970 Brazil 4-1 won 1962 Brazil 3-1 won 1958 Brazil 5-2 won ; data european; title "European World Cup Finalists From 1954 to 1998"; input Year $ Country $ 9-23 Score $ 25-28 Result $ 32-36; datalines; 1998 France 3-0 won 1994 Italy 2-3 lost 1990 West Germany 1-0 won 1986 West Germany 2-3 lost 1982 Italy 3-1 won 1982 West Germany 1-3 lost 1978 Holland 1-2 lost 1974 West Germany 2-1 won 1974 Holland 1-2 lost 1970 Italy 1-4 lost 1966 England 4-2 won 1966 West Germany 2-4 lost 1962 Czechoslovakia 1-3 lost 1958 Sweden 2-5 lost 1954 West Germany 3-2 won 1954 Hungary 2-3 lost ;
options pagesize=60 linesize=80 pageno=1 nodate; proc sort data=southamerican;1 by year;1 run; proc print data=southamerican; title 'World Cup Finalists:'; title2 'South American Countries'; title3 'from 1954 to 1998'; run; proc sort data=european;1 by year;1 run; proc print data=european; title 'World Cup Finalists:'; title2 'European Countries'; title3 'from 1954 to 1998'; run;
The PROC SORT statement sorts the data set in ascending order according to the BY variable. To create the interleaved data set in the next example, the data must be in ascending order. |
World Cup Finalists by Continent
World Cup Finalists: 1 South American Countries from 1954 to 1998 Obs Year Country Score Result 1 1958 Brazil 5-2 won 2 1962 Brazil 3-1 won 3 1970 Brazil 4-1 won 4 1978 Argentina 3-1 won 5 1986 Argentina 3-2 won 6 1990 Argentina 0-1 lost 7 1994 Brazil 3-2 won 8 1998 Brazil 0-3 lost
World Cup Finalists: 2 European Countries from 1954 to 1998 Obs Year Country Score Result 1 1954 West Germany 3-2 won 2 1954 Hungary 2-3 lost 3 1958 Sweden 2-5 lost 4 1962 Czechoslovakia 1-3 lost 5 1966 England 4-2 won 6 1966 West Germany 2-4 lost 7 1970 Italy 1-4 lost 8 1974 West Germany 2-1 won 9 1974 Holland 1-2 lost 10 1978 Holland 1-2 lost 11 1982 Italy 3-1 won 12 1982 West Germany 1-3 lost 13 1986 West Germany 2-3 lost 14 1990 West Germany 1-0 won 15 1994 Italy 2-3 lost 16 1998 France 3-0 won
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.