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?
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;
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.
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.
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.
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;
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!
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.