Architecting, installing and maintaining your SAS environment

sas linux redirecting log

Accepted Solution Solved
Reply
Super Contributor
Super Contributor
Posts: 373
Accepted Solution

sas linux redirecting log

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?

 

 


Accepted Solutions
Solution
‎10-23-2017 03:51 PM
Super User
Posts: 8,054

Re: sas linux redirecting log

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 8,054

Re: sas linux redirecting log

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Regular Contributor
Posts: 211

Re: sas linux redirecting log

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.

 

Super Contributor
Super Contributor
Posts: 373

Re: sas linux redirecting log

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,
Solution
‎10-23-2017 03:51 PM
Super User
Posts: 8,054

Re: sas linux redirecting log

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Super Contributor
Posts: 373

Re: sas linux redirecting log

Posted in reply to KurtBremser
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/.

Regular Contributor
Posts: 211

Re: sas linux redirecting log

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

 

 

 

Super Contributor
Super Contributor
Posts: 373

Re: sas linux redirecting log

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-
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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