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".
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.