Wednesday, March 4, 2015

INITSTMT/TERMSTMT with %include

Here is scenario: You have to test many batches manually. As the jobs are for different projects, you want to setup environment at the beginning of SAS session, or send out analysis report at the end of SAS session. However, you can not change any existing configuration and program. Here I want to show how I handle them using system options INITSTMT/TERMSTMT.
$ alias sasp='/(saspath)/sas_batch.sh 
-initstmt "%let a=%sysfunc(quote(/work/scripts/initstmt.sas));%inc &a;" 
-termstmt "%let b=%sysfunc(quote(/work/scripts/termstmt.sas));%inc &b;" '

$ sasp code.sas -log code.(timestamp).log
Why I use "quote" function? As the shell may be confused with quotation.

No comments: