BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mcrum1
Calcite | Level 5

If I want to run a program all the way through and before the program finishes running, have it rerun the middle section to the end of the program one more time, how would I do that?

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Hope that helped.  Just to clarify what I meant by popping a macro/mend around the code which I didn't explain above.  Use something like the below:

/* This code to run once */

...

...

...

%macro Code_to_run_twice();

     ...

     ...

     ...

%mend Code_to_run_twice;

%Code_to_run_twice;

%Code_to_run_twice;

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Errrm, you can't.  Once a program is submitted then it runs through to the end.  You can cancel submitted programs.  Could you define in more detail why you would want to do this?  If the second half or your program needs to run twice, why not just pop a macro and mend around the code and call the macro twice?

Or highlight the first part of the code, execute that, then highlight the second part, run that, then submit it again.

mcrum1
Calcite | Level 5

A part of the program I run twice.  I run the program all the way through, then immediately rerun a section of the program. This corrects the underlying data due to errors people make when they make changes.  Errors include improper end dates (end dated before month end) or reassignments to other groups. 

Hopefully I’m explaining this okay. I’m pretty new to this to using SAS. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Ah, so you are doing some data cleaning, then some further operations on the clean data.  I would then suggest that you would be better served setting up a staging process for this:

Raw Data -> Data Cleaning Checks -> Clean Data

Clean Data -> Output Programs

You may find yourself having difficulties latter on with things changing, lack of audit trail etc.

You can still do it in one program, just create temporary datasets:

data processed_data;

     set raw_data;

     do some edit checking/re-assignment;

run;

proc report processed_data;

     ...

run;

If you need further info or help, post some test data and the parts of your code you are re-running and we could suggest further items.  Am not in office now, so would be tomorrow.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Hope that helped.  Just to clarify what I meant by popping a macro/mend around the code which I didn't explain above.  Use something like the below:

/* This code to run once */

...

...

...

%macro Code_to_run_twice();

     ...

     ...

     ...

%mend Code_to_run_twice;

%Code_to_run_twice;

%Code_to_run_twice;

mcrum1
Calcite | Level 5

I tried both responses and they both worked. Just so I didn't have to divide the program I used the %macro %mend.

Thank you both!

jakarman
Barite | Level 11

divide you code into several parts storing the in segegrated locations.

Having the program run use the %include to call (bring the code) into running. Needed to run twice, do the %include twice.

---->-- ja karman --<-----

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 1555 views
  • 3 likes
  • 3 in conversation