BookmarkSubscribeRSS Feed
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:



%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\";
%INCLUDE "&folder\dssINPUT.SAS";
%INCLUDE "&folder\ngaINPUT.SAS";
%INCLUDE "&folder\ddsmain.SAS";



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



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

From SAS Users blog
Want more? Visit our blog for more articles like these.
5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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