33 %local d_temp1 d_temp2;
34 data; run; %let d_temp1=&syslast;
35 data; run; %let d_temp2=&syslast;
36 %local i count bycount;
39 proc sort data=&data out=&d_temp1;
42 %
if &syserr %then %
do;
43 %put ERROR: Macro Generate: data= or by= specified incorrectly;
48 proc means noprint data=&d_temp1(keep=&by);
54 set &d_temp2 nobs=count;
55 call symput (
"count", compress(put(count,8.)));
65 array t(1) $ 200 _temporary_;
68 %
do %
while(%scan(&by,&i) ne %str());
70 t(1) = trim(t(1)) !!
',';
72 t(1) = trim(t(1)) !!
" %scan(&by,&i)=" !! trim(left(vvalue(%scan(&by,&i))));
75 %let bycount=%eval(&i-1);
76 t(1) = trim(t(1)) !!
' (' !! compress(put(_freq_,8.)) !!
' observations)';
77 call symput (
'label' !! compress(put(_n_,8.)), trim(t(1)));
81 data %
do i=1 %to &count; &out&i (label=
"&&label&i") %end; ;
84 array t(1) _temporary_;
85 if first.%scan(&by,&bycount) then t(1)+1;
88 when(&i) output &out&i;
93 proc datasets lib=work nolist;
94 delete %scan(&d_temp1,2,.) %scan(&d_temp2,2,.);