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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: