This is my first post so apologies for any faux pas...
I want to create a dataset using a DATA step in a macro. In the dataset I use a WHERE step, which I want to be dependent on the macro variable (TABLE).
So I've written the following but it doesn't work. It just takes it as "...WHERE FINANCIAL_ID IN (5);..."
I've tried many different things with this but can't get it to work... Any ideas would be most welcome.
%MACRO LOSSES(TABLE);
DATA INS_RSK_&TABLE;
SET INS_RSK_S;
WHERE FINANCIAL_ID IN (5, %IF &TABLE="LN" %THEN %DO; %PUT %STR(,9); %END;);
RUN;
%MEND;
Thank you very much.
Maybe this example can help you:
%macro test(var);
data table;
set sashelp.class;
where age in (12 %if &var=fourteen %then ,14 ; );
run;
%mend;
%test(fourteen)
%test(notfourteen)
Maybe this example can help you:
%macro test(var);
data table;
set sashelp.class;
where age in (12 %if &var=fourteen %then ,14 ; );
run;
%mend;
%test(fourteen)
%test(notfourteen)
Thank you very much!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.