I have followed your step for Homework .
Third step ( Merge dataset in step 1 with step 2 by trt01pn*/), I got an error message.
I have pasted the log for 3rd step.
1) Get the count for number of patients in each treatment group = PT_TRT ( 2 observation and 2 variables)
/*2. sort alln by trt01pn*/
/*3. Merge data set pt_count and alln by trt01pn*/
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
42 ;
43 /* homework* step 1*/
44 proc summary data = pt_trt;
45 class usubjid trt01pn;
46 output out = pt_count;
47 run;
NOTE: There were 23 observations read from the data set WORK.PT_TRT.
NOTE: The data set WORK.PT_COUNT has 49 observations and 4 variables.
NOTE: PROCEDURE SUMMARY used (Total process time):
real time 0.03 seconds
cpu time 0.05 seconds
48 proc print data = pt_count;
49 run;
NOTE: There were 49 observations read from the data set WORK.PT_COUNT.
NOTE: The PROCEDURE PRINT printed page 24.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.46 seconds
cpu time 0.48 seconds
50 /* sort alln by trt01pn*/
51 data alln;
52 set nbody ndecod;
53 run;
NOTE: There were 41 observations read from the data set WORK.NBODY.
NOTE: There were 136 observations read from the data set WORK.NDECOD.
NOTE: The data set WORK.ALLN has 177 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
54
55 proc sort data = alln;
56 by trt01pn;
57 run;
NOTE: There were 177 observations read from the data set WORK.ALLN.
NOTE: The data set WORK.ALLN has 177 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
58 proc print data = alln;
59 run;
NOTE: There were 177 observations read from the data set WORK.ALLN.
NOTE: The PROCEDURE PRINT printed pages 25-28.
NOTE: PROCEDURE PRINT used (Total process time):
real time 1.35 seconds
cpu time 1.39 seconds
60 /* Merge data set pt_count and alln by trt01pn*/
61
62 data pct;
63 merge pt_count alln;
64 by trt01pn;
65 run;
ERROR: BY variables are not properly sorted on data set WORK.PT_COUNT.
USUBJID= trt01pn=1 _TYPE_=1 _FREQ_=1 AEBODSYS=Blood and lymphatic system disorders AEDECOD= FIRST.trt01pn=0 LAST.trt01pn=1 _ERROR_=1 _N_=23
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 4 observations read from the data set WORK.PT_COUNT.
NOTE: There were 23 observations read from the data set WORK.ALLN.
WARNING: The data set WORK.PCT may be incomplete. When this step was stopped there were 22 observations and 6 variables.
WARNING: Data set WORK.PCT was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
66 proc print data =pct;
67 run;
NOTE: There were 22 observations read from the data set WORK.PCT.
NOTE: The PROCEDURE PRINT printed page 29.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.26 seconds
cpu time 0.27 seconds
68 ;
69 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
79 ;