sas macro in proc sql -
i have problem simple can't figured out.
i have columns name1 c1 c2 c3 c4 .... c8
have sum names these columns , make new data.
here code wrote didnt work.
could please me?
proc sql; create table work.data1 select t1.name1, %let k=8 %macro test; %do i=0 %to &k; %sysfunc(sum(c&i)) c&i; %end; %mend test; %test; work.data t1 group t1.name1, quit;
data data; input name1 $ c1 c2 c3; datalines4; 1 2 3 1 2 3 b 1 2 3 b 1 2 3 ;;;; run; %macro test(k=); proc sql; create table work.data1 select t1.name1 %do i=1 %to &k.; , sum(c&i.) c&i. %end; work.data t1 group t1.name1; quit; %mend test; %test(k=3);
Comments
Post a Comment