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

Hello All,

 

What is the script to run a sas job on autosys in Unix environement. For windows we use .ps (powershell scripts) or .cmd (command line scripts). Can someone provide a template of the script?

 

Thanks,

Aj

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

In the root folder of your SAS Server context - i.e..../Lev/SASApp - you'll find a script sas.sh

 

Use this script in autosys and then just pass in the parameters you need. You can test the correctness of the command line by executing it out of a command prompt (i.e. via Putty).

 

.../sas.sh -sysin <your SAS program> -log <same name as SAS program, add a timestamp to the name> .....

 

Using sas.sh has the advantage that all your .cfg adn autoexec's will get executed for the server context and though your batch jobs will get the same environment than what you've used during development via SAS EG or the like.

 

View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

Could you post the template for the .cmd Windows batch file?

From this, one could deduce the requirements for a UNIX shell script.

 

It is also most important to know how autosys passes control parameters to jobs.

AjayPrasad
Fluorite | Level 6

Below is the script for .cmd Windows batch file to run on autosys.

 

 "C:\sas94\sashome\SASFoundation\9.4\sas.exe"  -config "C:\sas94\sashome\SASFoundation\9.4\nls\en\SASV9.CFG" -sysin "G:\ANALYTICS\SAS_CODE\Program\Program.sas" -LOG "G:\ANALYTICS\SAS_LOGS\Program\Program.log" -PRINT "G:\ANALYTICS\Reports\Program\Program.lst" -xcmd -noxwait -xsync -nosplash -icon -rsasuser

 

Do we have a similar template for Unix?

Patrick
Opal | Level 21

In the root folder of your SAS Server context - i.e..../Lev/SASApp - you'll find a script sas.sh

 

Use this script in autosys and then just pass in the parameters you need. You can test the correctness of the command line by executing it out of a command prompt (i.e. via Putty).

 

.../sas.sh -sysin <your SAS program> -log <same name as SAS program, add a timestamp to the name> .....

 

Using sas.sh has the advantage that all your .cfg adn autoexec's will get executed for the server context and though your batch jobs will get the same environment than what you've used during development via SAS EG or the like.

 

AjayPrasad
Fluorite | Level 6

Few questions running in my mind

1.Do I need to modify any lines in sas.sh ?

2.What command line should I use in the autosys. For example if I have a program.sas, I would create a command script at a location and give that path in the command on autosys. It may look like this \\servername\filepath\program.cmd or \\servername\filepath\program.ps1.

 

Please clarify!

Patrick
Opal | Level 21

Do I need to modify any lines in sas.sh ?

I wouldn't change sas.sh at all but you can always create and use a copy of the file and then add whatever modifications you like. The one thing I'm normally adding is a cd command pointing to the log directory so that any unspecified output goes there.

 

2.What command line should I use in the autosys.

You can use pretty much the same than what you've posted for Windows - just with different paths. As for the command posted for Windows: I would have used the sas.bat file there as well instead of the sas.exe (same reason: gives you the server context specific environment under which you've likely developed and unit tested your code).

 

@LinusH wrote: If you are using data integration the deployed job contains the full command line.

 

I've used such a command line from my Windows environment and below how this looks like (with some amendments):

/<root path>/SAS/Config/Lev1/SASApp/BatchServer/sasbatch.sh 
-sysin /<root path>/SAS/Config/Lev1/SASApp/SASEnvironment/SASCode/Jobs/my_prog.sas
-log /<root path>/SAS/Config/Lev1/SASApp/BatchServer/Logs/my_prog_#Y.#m.#d_#H.#M.#s.log  
-logparm "rollover=session"  
-batch 
-noterminal 
-print /<root path>/SAS/Config/Lev1/SASApp/BatchServer/Logs/my_prog.lst

 

You can see that it uses /BatchServer/sasbatch.sh. You can use this one as well if a batch server exists in your environment and there if you need to add any amendments to the script then add them to sasbatch_usermods.sh (it's already all there prepared and waiting for you - too easy).

 

Other possible amendments:

You could write a wrapper script which then includes sasbatch.sh or add changes directly to the sasbatch_usermods.shfile. You could for example add some parameter processing like: Instead of having to pass in fully qualified paths to -sysin, -log and -print add these paths as part of your script. You could for example on the outermost level only require to pass in the SAS program name without a path and then you add all the rest within your custom wrapper script (or within sasbatch_usermods.sh). This would make the command line you have to pass to Autosys much shorter.

Same is true for any additional parameters like -noterminal which you always want set for batch processing. 

AjayPrasad
Fluorite | Level 6

Thanks for a great and best explanation. This completely helped me fix my script.

LinusH
Tourmaline | Level 20
If you are using data integration the deployed job contains the full command line.
Data never sleeps

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