BookmarkSubscribeRSS Feed
tunnii
Fluorite | Level 6

Hi, please help me create a UNIX module to run and rerun sas programs dependently. If sample1.sas fails will rerun and not continue will sample2.sas and sample3.sas

 

4 REPLIES 4
Kurt_Bremser
Super User

Look at the conditional operators in UNIX shells:

command1 && command2

means that command2 will only be run if command1 succeeds

command1 && command2 || command3

if command1 succeeds, run command2, else run command3

 

for loop structures in UNIX shells, see https://www.tutorialspoint.com/unix/unix-shell-loops.htm. You'll also find lots of other information for shell scripoting on that website.

Patrick
Opal | Level 21

@tunnii

I'd use a scheduler like LSF for a production system. Enterprise grade schedulers are built for handling such dependencies.

tunnii
Fluorite | Level 6

Thank you for you replies,really helpful. In the UNIX Script. create a loop to test the sas program is fail or success. If Fail sleep for a minute to check error. Script will rerun until success then go to next sas progran.

 

f=sasprogram
for f in saslist
	do
		sas sasdirectory/$f -log /sas_log/$f.$date.log
		until [ $? -eq 0 ];
		do
		  echo "Processing $f: job fail...\n"
		  echo "Please see error details" /sas_log/$f.$date.log
		  sleep 60 *1 minute
		  sas $sas_dir/$f -log $sas_log/$f.$dateparm.log
		done
		"Processing $f: job success...\n" 
	done
exit 0

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 755 views
  • 4 likes
  • 3 in conversation