BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Is there any possible to access multiple dataset by using %let
dataset names x,y,z.
we can use SET statement similary in Macros
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
This is not really an ODS or BASE SAS reporting procedure question (PRINT, REPORT, TABULATE).

For help with SAS macro processing, there is no better reference than the SAS Macro Facility documentation. If you have a particular SAS Macro question, then you might find better and more timely help by contacting SAS Technical Support.

In general however, there is no "accessing of multiple datasets" done by the SAS Macro facility. The SAS Macro facility generates code. It acts like a big typewriter.

If you have this code that defines 2 macro variables:
[pre]
%let wombat = Twas brillig and the slithy toves;
%let koala = Did gyre and gimble in the wabe;

[/pre]

you are creating 2 macro variables, &WOMBAT and &KOALA that are just text strings. You can't do much with 2 snippets of a poem in a SAS program however, except make them variable values:
[pre]
data jabberwocky;
line = "&wombat";
output;
line = "&koala";
output;
run;

proc print data=jabberwocky;
run;
[/pre]

However, if you had a %LET statement like this:
[pre]
%let mydata = sashelp.prdsale sashelp.prdsal2;
[/pre]
Then the macro variable &MYDATA is only holding the text string which is 2 file names -- the 2 files are not "accessed" by the macro facility.

However, if you have a working SAS program:
[pre]
data newfile;
set sashelp.prdsale sashelp.prdsal2;
run;
[/pre]

then you have a place in that working SAS program where you could USE the macro variable:

[pre]
data newfile;
set &mydata;
run;
[/pre]

Now, it is the DATA step program that is accessing the 2 data files. The macro variable is just a convenience or a shortcut that you use on the SET statement. Now you could write something like this:
[pre]
data Germany;
set &mydata;
if country = 'GERMANY' then do;
.... more code;
output;
end;
run;

data USA;
set &mydata;
if country = 'USA' then do;
... more code;
output;
end;
run;
[/pre]

Of course, there are more efficient ways to create multiple datasets, however, the above example shows an instance where you might want to use the macro variable &MYDATA more than 1 time, in more than 1 program.

To contact Tech Support, go to http://support.sas.com and on the left hand navigation area, look for the link, entitled "Submit a Problem" in order to send your question to Tech Support.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 647 views
  • 0 likes
  • 2 in conversation