BookmarkSubscribeRSS Feed
Gexern
Fluorite | Level 6

Hi SAS Community

 

I am using SAS (foundation?) 9.4 and have about 10 programs, where the first 5 can run serially, and the next 5 can only run after the first ones are done.

 

I have therefore made a batch program that run the codes as I need them. Sometimes I need to make a change to the "downstream" program, so that I need to run the batch again. I usually run the batch at night, as it takes several hours to run. If I have made an error half way, it would be nice to be able to fix the code and rerun from that point, but in batch mode this is not immediately possible.

 

I discovered the checkpoint system, and if I understood correctly when I run the batch file i use this code (probably without nowirkinit):

 

sas -sysin 'c:\mysas\mysasprogram.sas' -stepchkpt -steprestart -noworkinit 
   -noworkterm  -errorcheck strict -errorabend

If one of the programs fail, I can restart from checkpoint with this code:

 

sas -sysin 'c:\mysas\mysasprogram.sas' -stepchkpt -steprestart -stepchklib 
   mylibref -errorcheck strict -errorabend

My question is if this works if I make changes to the sas program before I restart it? Will it recognize it as the same step and start from the correct checkpoint? Or is there some way to make "manual" checkpoints within the code, in which it can start from?

1 REPLY 1
Kurt_Bremser
Super User

Split your code into usefully discrete parts (each in its own .sas file), and run them from a single shell script. Have the shell script look for a parameter that, if set, determines where to start:

STEP=$1
if [[ $STEP < 2 ]]
then
  echo "running first program"
fi
if [[ $STEP < 3 ]]
then
  echo "running second program"
fi

When run without a parameter, it does this:

user@server:/home/user $ ./test.sh
running first program
running second program

When run with parameters, it does this:

user@server:/home/user $ ./test.sh 1
running first program
running second program
user@server:/home/user $ ./test.sh 2
running second program
user@server:/home/user $ ./test.sh 3
user@server:/home/user $ 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 322 views
  • 1 like
  • 2 in conversation