BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mayankdce1
Fluorite | Level 6

Hi,

 

I have a windows directory in which I have created a few macros as .txt files. I want to store the names of these text files in to a sas macro. The intent is that I want to declare (%include) all macros within that directory using this sas macro instead of asking user to enter all the macros one by one. Please note that each text file contains some lines of sas codes (and no data)

 

Thanks!

Mayank

1 ACCEPTED SOLUTION
4 REPLIES 4
mayankdce1
Fluorite | Level 6
Thank you for a prompt response. As a quick fix, I have created a small macro. But, I am also simultaneously looking into sasautos to get more understanding.

%macro declare_macros;
%let file_path = &toolkit.;
filename dirlist pipe "dir ""&file_path"" /b ";

data dirlist;
infile dirlist missover pad;
input filename $1000.;
run;

data _null_;
set dirlist;
id = _n_;
call symputx("nobs",strip(id));
call symput('macro' || left(put(_n_, 4.)), trim(filename));
run;

%do ii = 1 %to &nobs.;
%include "&toolkit.&&macro&ii.";
%end;
%mend declare_macros;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Thats not a quick fix, thats a very long fix, which may not work all the time and isn't portable.  

options sasautos=(&toolkit.);

Is a quick fix.

mayankdce1
Fluorite | Level 6

Thank you, again. It worked! Much simpler method.

 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 882 views
  • 4 likes
  • 2 in conversation