I have several separate SAS codes inside a process flow. Now I want to add loops (by year and lookback) on top of the SAS codes starting from ”2-extract input files” (see the figure attached) to the end. Of course I can put all the codes together and add a Macro like:
%MACRO mFilter(nYr_, lookback_);
Read in macro variables and put all needed codes here
%MEND;
* run multiple years;
%MACRO mMain(nYr1_, nYr2_, lookback_);
%DO y = &nYr1_ %TO &nYr2_;
%DO x = 1 %TO &lookback_;
%mFilter(&y, &x)
%END;
%MEND;
%mMain(&mYear1, &mYear2, &mLookback); * values given;
My question is: Can SAS EG do the loops easily by adding prompts or other ways to the programs or to the process flow while keeping the SAS code programs separate so that it is easy to check logs, and if yes, can you provide details ?
Thanks a lot.
Assuming you organize your individual programs within a project as a flow (linked programs) which all execute on the same server and same session:
You could add two additional code nodes and link them into your flow - A) where your loop macro needs to begin, B) where your loop macro needs to end.
Node A) would have code like:
%macro Loop(stop=); %do i=1 %to &stop; .....
Node B) would have matching code like:
... %end; %mend; %Loop(stop=&Param_From_Prompt);
... and then define the Prompt with name (here in the example) Param_From_Prompt.
Thanks for the response. I will give a try
Thanks for the info.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.