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".
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.