SAS (Base SAS)+
data adsl;
input studyid $ usubjid $ trt01pn age fasfl $ trt01p :$20.;
datalines;
MYCSG MYCSG-1001 1 23 Y "Dose level 1"
MYCSG MYCSG-1002 3 68 Y "Dose level 3"
MYCSG MYCSG-1003 3 . Y "Dose level 3"
MYCSG MYCSG-1004 3 35 Y "Dose level 3"
MYCSG MYCSG-1006 3 54 Y "Dose level 3"
MYCSG MYCSG-1007 1 63 N "Dose level 1"
;
run;
proc format;
value treatment
1=1
2=2
3=3
4=4
;
run;
data adsl02;
set adsl;
where fasfl="Y";
treatment=trt01pn;
output;
treatment=4;
output;
run;
proc summary data=adsl02 nway completetypes;
class treatment/preloadfmt;
var age;
output out=stats01 n= nmiss= mean= std= min= q1= median= q3= max= /autoname;
format treatment treatment.;
run;data adsl02;filters to the flagged rows (where fasfl = "Y") and duplicates each record — once with its real treatment, once withtreatment = 4(the Total band).proc format; value treatment 1=1 2=2 3=3 4=4;declares that 1-4 are the valid treatment codes; this matters because we ask PROC SUMMARY to use the format later.proc summary data=adsl02 nway completetypes; class treatment / preloadfmt;tells SAS to include every formatted level in the output, even ones with no rows.var age;names the analysis variable; theoutputstatement lists the statistics we want.output out=stats01 n= nmiss= mean= std= min= q1= median= q3= max= / autoname;writes one statistic per column with auto-generated names likeage_n,age_mean.- After running, STATS01 has one row per treatment band — 1, 3, and 4 (Total) in this sample; adjust
adsl02or the format if other levels appear in the production data.