본문 바로가기

SAS/Scenario

Scenario 1

 

 

This scenario uses the Cert.Patient and Cert.Measure data sets.

Write a SAS program to do the following:

  • Sort Cert.Patient and Cert.Measure by ID.
  • Use the match-merging technique to combine Cert.Patient and Cert.Measure to create a new temporary data set named Work.Merge.
  • Select observations for the patients under the age 50.
  • Sort the new data set, Work.Merge, by Age in decending order.
  • Save the sorted data set as Work.Sortpatients.

 

 

[사용 코드]

 

libname cert 'C:/folders/mypath/cert/' ;
proc sort data=cert.patients out=work.patients;
by id;
run;


proc sort data=cert.measure out=work.measure;
by id;
run;

data work.merge;
   merge work.patients work.measure;
   by id;
   if age < 50;
   run;


proc sort data=work.merge out = work.sortpatients;
by decending age;
run;

proc print data=work.sortpatients;
run;

 

  • PROC SORT에 out= 쓰는 것 주의하기 !

 

(좌)  sort 전 Work.Merge     (우) Work.Sortpatients

 

'SAS > Scenario' 카테고리의 다른 글

Scenario 3  (0) 2022.12.25
Scenario 2  (0) 2022.12.25
Scenarie 10  (0) 2022.11.06
Scenario 9  (1) 2022.11.06
Scenario 8  (0) 2022.11.06