Hello,
I am new to SAS and I was given this macro,
%mend create_libraries;
%create_libraries;
%macro Dt_extract(directory);
proc sql noprint;
select count(*)
into:n_names
from &directory..flname_ann;
quit;
%do z=1 %to &n_names;
data _null_;
a bunch of code
%end;
%mend Dt_extract;
%Dt_extract(temp);
There is data set name flname_ann. Within it is a list of all the names of SAS dataset that I want to go through. So this macro essentially goes through all the dataset, do some modification and towards the end I add in a proc append and end up with a new table with all the modified dataset combined.
Now, within the same folder where I save the flname_ann file, there is another similar dataset with another list of files that I wish to go through. Can someone please explain to me how can I call up the same macro to read this other file, named flname_non?
Thank you very much in advance.
This is untested but it should work.
%macro Dt_extract(directory=,file=);
proc sql noprint;
select count(*)
into:n_names
from &directory..&file.;
quit;
%do z=1 %to &n_names;
data _null_;
a bunch of code
%end;
%mend Dt_extract;
%Dt_extract(directory=temp,file=flname_ann);
%Dt_extract(directory=temp,file=flname_non);
It works perfectly! Thank you very much.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.