when I run the sas code below, it does not generate the table. What am I doing wrong? Thanks.
%macro createData(test=);
%if 2+2 = 4 %then %do;
proc sql;
create table test as
select
*
from datasets.mydata
;
quit;
%end;
%mend;
That code runs fine as long as you actually call the macro!
You need one more line:
%createData(test=1);
(test=1
is arbitrary, since you don't do anything with the &test
macro parameter I just picked whatever I wanted).
SAS Macros are similar in other programming languages to methods - they don't do anything until they're called, running the macro definition itself just compiles the macro and gets it ready to be used.