I have a macro variable %let state= CA. How can use it within a macro in a conditional statement.
I want to create a dataset that is a subset. This does not work:
proc sql; create table &state. as select * from &data.(where = (top_states=&state.)); quit;
But this works:
proc sql; create table &state. as select * from &data.(where = (top_states='CA')); quit;
How can I use the &state. macro to subset my data?
Modify as below:
proc sql;
create table &state. as
select * from &data.(where = (top_states="&state"));
quit;
Unlike single quotes, the use of double quotes permits the macro compiler to interpret "&state" as "CA".
Modify as below:
proc sql;
create table &state. as
select * from &data.(where = (top_states="&state"));
quit;
Unlike single quotes, the use of double quotes permits the macro compiler to interpret "&state" as "CA".
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.