BookmarkSubscribeRSS Feed
radha009
Quartz | Level 8

To secure the code. Instead using SAS tool to execute the program.Can you please help if we can write a shell script and execute the program. I created a program as below shell script and run in LINUX but it is not working.

 

Code:

#!/usr/bin/sh
dtstamp =$(date +%Y.%m.%d_%H.%M.%S)
pgmname ="/SAS/Code/Infra/Application_Validation.sas"
logname = "/SAS/Code/Infra/Application_Val_$dtstamp.log"
/sas/SASHome2/x86/SASFoundation/9.4/sas $pgmname -log $logname

 

 

Errors:

 

user/SAS/Code/infra>sh program.sh
program.sh: line 2: dtstamp: command not found
program.sh: line 3: pgmname: command not found
logname: extra operand `='
Try `logname --help' for more information.
program.sh: line 5: /sas/SASHome2/x86/SASFoundation/9.4/sas: No such file or directory

6 REPLIES 6
Ksharp
Super User
/*** must have only one line **/

/sas/SASFoundation/9.4/sas
-sysin /home/sas/xxxx.sas
-config /location/sas/sasv9.cfg
-noterminal
-unbuflog
-log "/location/sas/log/xxxx_%Y%m%d.log"
-logparm "rollover=auto open=append write=immediate"
-memsize 0
-sortsize 1G
Kurt_Bremser
Super User

Blanks are the natural separators in any shell scripting language, so you must be careful in their use.

When setting an environment variable, the equal sign has to immediately follow the variable name.

This will fail:

$ dtstamp =$(date +%Y.%m.%d_%H.%M.%S) 

while this will work:

$ dtstamp=$(date +%Y.%m.%d_%H.%M.%S) 
$ echo $dtstamp
2018.11.30_14.35.08
Kurt_Bremser
Super User

Oh yeah, and

program.sh: line 5: /sas/SASHome2/x86/SASFoundation/9.4/sas: No such file or directory

simply means you entered an incorrect path name to your SAS executable. Browse your file system for the correct location.

Kurt_Bremser
Super User

And it's best to use a shell script that SAS has prepared for running batch programs. It's called sasbatch.sh and located in /sasconf/Lev1/SASApp/Batchserver. It will use the same configuration you find in your SASApp server in SAS Studio or EG.

radha009
Quartz | Level 8

I am using windows SAS for creating programs. Can i copy the scripts to unix server and execute the program as the above script.

in SAS properties i have the same patch.

Kurt_Bremser
Super User

Very naturally, you cannot use Windows batch files as shell scripts on UNIX systems. That's why I suggest to use the sasbatch.sh provided by SAS in the BI Server environment.

 

And I don't understand what you mean by

"in SAS properties i have the same patch."

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2795 views
  • 0 likes
  • 3 in conversation