Saturday, December 20, 2008

Capturing the data into a macro

-
For the display of (N=xx) in a summary table, we have to capture the data into a macro. There are two different methods for capturing the data into a macro. One is using PROC SQL & the other one is using CALL SYMPUT.
-
***** GETTING "N" FOR EACH TRT GROUP *****;
-
1) PROC SQL:
-
data total;
set main(where=(saf=1));
trtgrp = input(treat,best.);
output;
trtgrp = 3;
output;
run;
-
proc sql noprint;
select count(distinct usubjid) into : trt1 through : trt3 from total group by trtgrp;
quit;
%put &trt1 &trt2 &trt3;
-
2) SYMPUT:
-
proc freq data = total noprint;
tables trtgrp / out = deno(drop = percent) list missing;
run;
-
data _null_;
set deno;
if trtgrp=1 then call symput('trt1',trim(left(put(count,3.))));
if trtgrp=2 then call symput('trt2',trim(left(put(count,3.))));
if trtgrp=3 then call symput('trt3',trim(left(put(count,3.))));
run;
-

No comments:

Post a Comment