BookmarkSubscribeRSS Feed
warboled
Calcite | Level 5

Hello everybody, I'm using sas enterprise guide and i need solve a problem of multiple executions of a flow.

 

I need execute a flow in meny times, that number is for each month from 2016-01 to now,  so i need a method for run it and it continue running repeatedly for every month.

3 REPLIES 3
Patrick
Opal | Level 21

@warboled

I'm not aware of any method in EG which would allow you to loop over a flow multiple times programmatically. 

 

On a coding level:

You could export all the code in the flow and copy this code into an EG code node, then wrap a macro around it and add a data step where you call the macro as many times as you like.

Below a code sample to illustrate the approach. The code within macro loopy is what you would copy from your current flow. You then would need to edit this code adding macro variable &rundate so you can pass in the month you process as parameter in the data step.

%macro loopy(rundate);
  data inter;
    format var date9.;
    var=&rundate;
  run;

  proc append base=want data=inter;
  run;
%mend;

data _null_;
  process_date='01JAN2016'd;
  do while(process_date<intnx('month',today(),0,'b'));
    call execute('%loopy('||process_date||')');
    process_date=intnx('month',process_date,1,'b');
  end;
run;
Kurt_Bremser
Super User

When posting, you were advised to use a descriptive subject line. Please do so in the future.

I edited your question accordingly.

Using just your username as the subject line is, ahem, not a very bright thing to do.

Kurt_Bremser
Super User

Another solution:

Export all code to a .sas file.

In the program, retrieve necessary values from environment variables with %sysget.

Then create a shell script that runs this program in a "for" loop and supplies the values in environment variables.

This would be precursor work for later handover to a scheduling system.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2594 views
  • 0 likes
  • 3 in conversation