- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a SAS program: test1.sas locates at /home/mysas/test1.sas in unix
I want to create a .sh file to run this test1.sas program, please advise.
I need to create the .sh file because I want use crontab to schedual running the sas program.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How would you run the program from a terminal?
The only extra thing you probably need to add is that you might need to source your startup files because the way that CRON runs your programs it does not normally run the startup files that normally run when you start your terminal session.
#!/bin/ksh #---------------------------------------------------------------------- # Make sure that my startup files run #---------------------------------------------------------------------- . /home/mysas/.profile #---------------------------------------------------------------------- # Move to the directory where we want to run the progs #---------------------------------------------------------------------- cd /home/mysas #---------------------------------------------------------------------- # Run the programs #---------------------------------------------------------------------- sas test1.sas
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!
How to add code in this .sh file to save log and output?
also can I add "&" in this .sh file for batch submit?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SAS provides already a sas.sh file for this purpose out of the box under your application server context,
i.e: .../Config/Lev1/SASApp/sas.sh or .../Config/Lev1/SASApp/BatchServer/sas.sh
If you need to amend it then create your own sas_usermods.sh and include sas.sh with dot notation as a starting point.
Using sas.sh has the advantage that it will already invoke your batch environment with all the definitions for the chosen application server context (so executing all the .cfg and .autoexec for this context).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SAS already knows how to save the LOG and LST for a program. If you run a program named "test1.sas" then it will automatically create a program named "test1.log" in the current directory to store the LOG and if you print anything to the listing output then it will also create a file name "test1.lst" to store that. If you don't like those names you can add the -log and -print options to the command line to change them.
If you are running this command from CRON then there is not really much need to add & to the end of the command since it is already running in the background. If you have two or three SAS programs you want fire up from the SAS script and you want them to run in parallel then you could add the &, but just remember that it means that any later steps you might want to have in there are not then guaranteed to run after the SAS program has finished.