The SAS Output Delivery System and reporting techniques

%let

Reply
N/A
Posts: 0

%let

Is there any possible to access multiple dataset by using %let
dataset names x,y,z.
we can use SET statement similary in Macros
SAS Super FREQ
Posts: 8,868

Re: %let

Posted in reply to deleted_user
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
Ask a Question
Discussion stats
  • 1 reply
  • 139 views
  • 0 likes
  • 2 in conversation