Desktop productivity for business analysts and programmers

Run same program several times in a row

New Contributor
Posts: 4

Run same program several times in a row

I have a process flow which includes a program that uses PROC SQL to join a dataset to an offset of a copy of itself and fill in some additional data.  I am supposed to re-run this program until there are no differences between the dataset and its copy (currently, I refresh the query output several times, then look at the proc compare output from a different program, then click refresh on the iterative query a bunch more times, check proc compare again, etc.).  As such there is no negative impact on the dataset from running the programs more times than necessary.

I would like to be able to run the process flow in a certain order, in the middle of which run my iterative query some large number of times (by construction it shouldn't take more than 35-50).  I tried using an ordered list, but it seemed like I was not able to add the same query more than once to the ordered list.

Is there any tool in EG to do what I have described?  Or something I can add to the program (which consists solely of a PROC SQL) to make the program perform the iteration 50 times?

Super User
Super User
Posts: 7,695

Re: Run same program several times in a row


Perhaps provide some test data and what you want out at the end.  At a guess, if what you want is a file to look like another, then use that as a template and work backwards rather than trying to loop over to get to it, reason being you then have a finite point to work for back to base, whereas the way your are doing it is: keep doing this until some criteria is met.

Posts: 57

Re: Run same program several times in a row

It sounds like you need a macro program with ordered steps.  The macro program would simply start by executing you compare.  If differences exist and you need run the remaining program, then the macro should execute the remaining steps.  Otherwise it should stop and perhaps display a message that there are no more iterations.

Regular Contributor
Posts: 226

Re: Run same program several times in a row

I have written a utility to run a program multiple times.

Routine CxInclude - sasCommunity

You will need to create a control data set with the parameters of the program.

Since you want to exit the loop on some condition

you'll have to add bypass logic inside the program being called.


is the trick

Using Functions SYSFUNC and IFC to conditionally execute statements in open code - sasCommunity

Ron Fehd  %include maven

Regular Contributor
Posts: 226

Re: Run same program several times in a row

... or you can put your program in a macro

and use this utility to run the loop

Macro CallMacr - sasCommunity

Ron Fehd  macro maven

see also

Ask a Question
Discussion stats
  • 4 replies
  • 1 like
  • 4 in conversation