Hi all, I need a little help with a macro. I basically need the below code to repeat exactly for the 9 treatment groups to create a dummy shell. I then the output from each treatment group to 'stack' as to create a large shell with 31 observations output from each treatment group. The away this is currently written, I am only getting output from group 'T" (the last entered group).
Help is appreciated!
%macro dummy (tx);
data dummy ;
do tx="&tx";
do ord=11 to 41;
if ord=11 then do;
do sord=1 to 2 ;
output;
end;
end;
if ord=21 then do;
do sord=1 to 8;
output;
end;
end;
if ord=31 then do;
do sord=1 to 12;
output;
end;
end;
if ord=41 then do;
do sord=1 to 9;
output;
end;
end;
end;
end;
run;
%mend dummy;
%dummy (A);
%dummy (B);
%dummy (C);
%dummy (D);
%dummy (E);
%dummy (F);
%dummy (G);
%dummy (H);
%dummy(T);
To get your program to work, get rid of the macro language. Take this statement:
do tx="&tx";
Change it to:
do tx = 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'T';
Then you can get rid of everything that is macro-related and be left with a DATA step.
As it stands now, each time you call the macro, you replace the data set DUMMY. That seems like the wrong thing to do.
To get your program to work, get rid of the macro language. Take this statement:
do tx="&tx";
Change it to:
do tx = 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'T';
Then you can get rid of everything that is macro-related and be left with a DATA step.
As it stands now, each time you call the macro, you replace the data set DUMMY. That seems like the wrong thing to do.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.