Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call mutliple datasets with one macro statement

Status
Not open for further replies.

sap1958

Technical User
Oct 22, 2009
138
0
0
US
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
 
Hi Sap,

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
 
Thanks it worked.

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
 
Looks like your syntax out, it should be...

%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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top