Skip to main content

Posts

Showing posts from May, 2016

How to run multiple SAS code in batch?

Issue: I have multiple SAS code file which I have to run sequentially. How to do that? Solution: Create a shell script file to invoke the sasbatch.sh. myprogram.sh: #!/bin/bash nohup /opt/sas/config/Lev1/SASApp/BatchServer/sasbatch.sh /home/sas/$1 -xcmd -nodms -log /home/sas/logs/$1.log -print /home/sas/listing/$1.lst & In above command you need to change the path depending on your environment. For example: in your organization the sasbatch.sh file may be in different location.  Create SAS file to call your SAS program: myprogram.sas: filename src '/sas//programs'; filename src1 '/home/sas/'; %include src(autoexec.sas); %include src1(first.sas); %include src1(second.sas); %include src1(third.sas); In the above code, I have pointed filename statement to where my autoexec.sas and SAS programs are located. I have mentioned src as /sas/programs, it is the location where my autoexec.sas file present. I have mentioned  src1

How to append log instead of creating new log for each run in SAS?

Issue: My program runs every hour. I need to create one log per day. So I need to append all the log generated by the code to a single file. Next day it should create the log in new file. How to do that? Solution: Use the logparm attribute as append. This option will append the log on the same file. -logparm "open=append" The batch code will be: /opt/sas/config/Lev1/SASApp/BatchServer/sasbatch.sh -sysin "myprogram.sas" -log "myprogram_`date +"%Y-%m-%d"`.log" -logparm "open=append" -print -noterminal You can see I have used date command to make it daily. You can change the occurence using that command. For more details about Logparam follow the below link: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002303556.htm