Suppose there is a table and in table ,a column named state has 28 different values.I want to call 5 states names, for this i want to write a single macro which will call those 5 states.
Kindly help.
It is not clear what you are asking for. A simple example of what you have and what you want to get would help.
If you are looking to subset your data then a WHERE statement (not a macro or a macro variable) is what you want.
You could use a macro variable to help you generate the WHERE statement.
%let state_list = 'NY' 'CT' 'DE' ;
data want;
set have;
where state in (&state_list);
run;
An actual macro is not needed unless you need to do something more complex.
You can use the "in" operator in where conditions, no macro needed.
To illustrate your issue, post example data in a data step with datalines (use the "little running man" icon for posting code), and what you expect to get out of it.
It is not clear what you are asking for. A simple example of what you have and what you want to get would help.
If you are looking to subset your data then a WHERE statement (not a macro or a macro variable) is what you want.
You could use a macro variable to help you generate the WHERE statement.
%let state_list = 'NY' 'CT' 'DE' ;
data want;
set have;
where state in (&state_list);
run;
An actual macro is not needed unless you need to do something more complex.
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.