BookmarkSubscribeRSS Feed
Brian_Chee
Calcite | Level 5

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.

2 REPLIES 2
jwillis
Quartz | Level 8

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);

Brian_Chee
Calcite | Level 5

It works perfectly! Thank you very much.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 800 views
  • 0 likes
  • 2 in conversation