BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

we install sas 9.4 on linux server and its a stand alone server. we run batch job using below command,

/path/to/sasbatch.sh /home/userid/test.sas -log /home/userid

 

we make alias "sas" for /path/to/sasbatch.sh and now running program like, 

sas /home/userid/test.sas -log /home/userid

 

we still want to simplify it and wants to run using below command,

sas test.sas 

 

what changes needs to be done to avoid writing full path to program when run from home dir and where to make changes so that logs gets redirect to home dir itself?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

If you can use an environment variable at all depends on where your SAS codes are stored.

If they are always found in a specific subdirectory of a user's home, you can use $HOME as a starting point.

If they are in a directory where each user has a subdirectory, you could use /sas_codes/$USER.

 

The executable that you want to use as "sas" (be it the SAS binary, or an alias for a script) needs to be in a directory contained in your system PATH. Otherwise xou will have to use the absolute path whenever you call it.

View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

You can make a copy of sasbatch.sh and adapt it so that it searches in specific directories for SAS codes and also puts the logs into specifc directories.

nhvdwalt
Barite | Level 11

On the assumption that all SAS source code is in the user's home directory, you could also use:

 

sas ~/test.sas

 

Drawback is that people will forget to include the "   ~/   ". But Kurt suggestion is a good one in that you can customize the script to make it foolproof.

 

woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10
i am not quite sure what environment variable i need to add into that script so that <sas test.sas> from command line would be possible,
Kurt_Bremser
Super User

If you can use an environment variable at all depends on where your SAS codes are stored.

If they are always found in a specific subdirectory of a user's home, you can use $HOME as a starting point.

If they are in a directory where each user has a subdirectory, you could use /sas_codes/$USER.

 

The executable that you want to use as "sas" (be it the SAS binary, or an alias for a script) needs to be in a directory contained in your system PATH. Otherwise xou will have to use the absolute path whenever you call it.

woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10
I tried to updating some file thinking it needs to be updated,

now I have PATH environment variable pointing to /home/utils (under /home, other users IDs are located). Updated my .bash_profile + sasenv_local file + @ /etc/profile. Also have alias SAS pointing to =/path/to/sasbatch.sh.
home dir has all sas code file and from where I am trying running it.

HOME environment variable pointing to -> /home/myid

but still when I run command,

sas test.sas

following error message pop up,

ERROR: Invalid file, /path-to/Lev1/SASApp/test.sas.

so it still looking for code file under .../SASApp/.

nhvdwalt
Barite | Level 11

SAS is probably being invoked from /path-to/Lev1/SASApp/, hence why it's looking for the code there.

 

Try changing the directory to the directory containing the code first, then invoked SAS. Something like:

 

cd /my_code_directory

sas test.sas

 

 

 

woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10
thanks i provided sas alias value to /path-to/sasfoundaiton/sas and now can execute job from home dir as -> sas test.sas.

Appreciate all for your response. Thanks-

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1555 views
  • 4 likes
  • 3 in conversation