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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 554 views
  • 1 like
  • 2 in conversation