Call mutliple datasets with one macro statement
Call mutliple datasets with one macro statement
(OP)
I have the following datasets:
inv01_2001_1;
inv02_2001_2:
inv02_2001_3; and so on
Is there such a macro as
%let inv01_2001_1,inv01_2001_2,inv02_2001_3 = inv;
Then call the macro in my statement such as
data inventory1;
set inventory;
?How would i call the macro into my data step. I want to avoid listing all of my inventories in the datastep
inv01_2001_1;
inv02_2001_2:
inv02_2001_3; and so on
Is there such a macro as
%let inv01_2001_1,inv01_2001_2,inv02_2001_3 = inv;
Then call the macro in my statement such as
data inventory1;
set inventory;
?How would i call the macro into my data step. I want to avoid listing all of my inventories in the datastep
RE: Call mutliple datasets with one macro statement
In the simplest terms yes
%let inv = inv01_2001_1 inv02_2001_2 inv02_2001_3;
data inventory1;
set &inv;
run;
This would be setting all the datasets in inv together.
If you have alot of datasets all the same name apart from the last number going up you could macro this to add 1 and loop
RE: Call mutliple datasets with one macro statement
Does this also work with actual numbers
%LET DrugCode IN( 00008084181,00008084199);
I inserted the above macro to capture these two drugcode numbers. When I ran the program the results left out both numbers
RE: Call mutliple datasets with one macro statement
%Let <Macro name> = <what you want it to equal>
When using %LET you're literally defining a word which replaces whatever.
So in your case it should be:
%Let DrugCode = IN(00008084181,00008084199);
And to call it &Drugcode