BookmarkSubscribeRSS Feed
hanahch
Calcite | Level 5

Hello SAS expert,

 

I have the following SAS program that uses macro variables to retrieve the folder name for individual cases and processes the data within each case folder. Currently, the program processes one case at a time, and since there are 100 case folders, it becomes impractical to manually select each case.  How can I modify the program so that it automatically retrieve the next case and repeat the process until all 100 cases have been handled. Your help is much appreciated.  Thank you!

 

Sample of case folder names:

hanahch_0-1690865314735.png

 


%LET id=1001B;             /** individual case folder name */

%LET folder=C:\DDS;

LIBNAME ddsdata "&folder";

options dlcreatedir;
libname newdir "&folder/OUTPUT";        /creates folder where processed data will be stored */

 

* the following lines run DDS programs;
%INCLUDE "&folder\dssformat.sas";
%INCLUDE "&folder\dssINPUT.SAS";
%INCLUDE "&folder\ngaINPUT.SAS";
%INCLUDE "&folder\ddsmain.SAS";

 

 

1 REPLY 1
Kurt_Bremser
Super User

You do not seem to use the macro variable id in the code.

 

Anyway: wrap everything into a macro definition with id as parameter. Create a dataset with all id's. Then call the macro from this:

data _null_;
set id_dataset;
call execute(cats('%nrstr(%your_macro(',id,'))'));
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 584 views
  • 1 like
  • 2 in conversation