The solution listed
below is one example of a program that could be used to accomplish
each task within each scenario. Your code can be different, so long
as it results in the same answers.
proc sort data=cert.patients out=work.patients; /*#1*/
by id;
run;
proc sort data=cert.measure out=work.measure;
by id;
run;
data work.merge; /*#2*/
merge work.patients work.measure; /*#3*/
by id; /*#4*/
if age<50; /*#5*/
run;
proc sort data=work.merge out=work.sortpatients; /*#6*/
by descending Age;
run;
proc print data=work.sortpatients; /*#7*/
run;
1 |
Sort Cert.Patients and Cert.Measure
by ID. You specify the DATA= option to specify the data set to sort.
The OUT= option specifies an output data set. The required BY statement
specifies the variable or variables to use in sorting the data.
|
2 |
The DATA step creates a new temporary
data set named Work.Merge.
|
3 |
The MERGE statement combines observations
from Work.Patients and Work.Measure into a single observation in a
new data set, Work.Merge, according to the values of a common variable.
|
4 |
The BY statement identifies the
variable that the MERGE statement uses to combine observations. During
match-merging, SAS sequentially checks each observation of each data
set to see whether the BY values match and then writes the combined
observation to the new data set.
|
5 |
The IF statement specifies that
only patients under the age of 50 are read into Work.Merge.
|
6 |
Sort Work.Merge by Age in descending
order. You specify the DATA= option to specify the data set to sort.
The OUT= option specifies an output data set. The required BY statement
specifies the variable or variables to use in sorting the data. The
DESCENDING option precedes the variable name.
|
7 |
The PROC PRINT step enables you
to view the contents of the sorted data set, Work.Sortpatients.
|
Output A2.1 PROC PRINT Output of Work.Sortpatients