Hi,
I am relatively new to SAS administration. I have installed SAS 9.3 in a Unix environment and also established connectivity with SQL Server. Now what I want to do is to customize SAS invocation command like below:-
SASt - Will connect to test server on SQL server
SASq - Will connect to QA server on SQL server
SASp - WIll connect to the SQL production server
Currently, I write ./sas to invoke SAS in my environment.
Any help in this matter will be greatly appreciated.
Let me know if additional information is needed.
Thanks in advance...
Instead of changing the default sas invocation, I would advise you to write a wrapper script and then let the wrapper invoke SAS with required customization.
Thanks for the suggestion. Could you please explain a bit more about this wrapper script?
Here is a simple wrapper script to invoke Base SAS:
#!/bin/sh -p
SASROOT=/path/to/SASFoundation/9.4
SAS_COMMAND=$SASROOT/sas
Quoteme() {
if [ $# -gt 1 ]; then
quoteme="\"$*\""
else
quoteme=$1
fi
}
cmd="$SAS_COMMAND"
for arg in "$@" ; do
Quoteme $arg
tmp="$quoteme"
cmd="$cmd $tmp"
done
eval exec $cmd
Hi Anand, Thanks for the reply.
I have to use a single odbc.ini file to connect to multiple SQL servers (test, prod, and uat) and databases. We have this kind of setup in our old server but now we moved to a new server (the person who set up the old server is no longer here), where I installed SAS but unable to replicate the way we used to invoke SAS i.e. SASp for production, SASq for test etc.
Here is a sample of an old SASd script: -
#!/usr/bin/ksh
. /home/sas9/sub.profile
cd /home/sasapps/uat/programs
#initialize batch parameter constants
BATCHPARMS="-work /home/tmp -nonews -rsasuser"
nice /home/sas9/sas $BATCHPARMS -autoexec "/home/sasapps/uat/programs/autoexec.sas" &
sub.profile: -
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.:\
/sybase11/bin:/home/sas9:/home/userid/utility
SYBASE=/sybase11
LIBPATH=/path/to/odbc/lib/file
LANG=en_US
ODBCHOME=/path/to/odbc
ODBCINI=/path/to/odbcini
export PATH SYBASE LIBPATH LANG ODBCHOME ODBCINI
autoexec.sas
filename senv '/path/to/sas/programs';
%global senvcode;
%global senvpath;
%let senvcode = %scan(%sysfunc(pathname(SENV,f)),-2,'/');
%let senvpath = %sysfunc(pathname(SENV,f));
options nonotes;
filename whoami pipe 'whoami';
data _null_;
infile whoami;
input;
if _infile_ eq 'poldenka' then call execute('%options_statement');
run;
options notes;
libname sasdata '/path/to/library/data';
libname saswrite '/path/to/library';
options sasautos=("%sysfunc(pathname(SENV,f))/sasmacro"
"/home2/sasapps/uat/programs/sasmacro"
'!SASROOT/sasautos'
);
Then from command line (old server) when I type commands like SASd, SASp, SASq, it invokes respective SAS and automatically connects to respective server.
Thanks in advance!!
I think I figured it out. I changed the path in old script to point to my current and respective path and it seems to be working now as when I use SASd command it opens SAS.
Thanks all for responses.
Set up separate application servers for the three contexts. Define the different library connections for the relevant servers.
We don't want to set up multiple servers.
@ashrivastava wrote:
Hi,
I am relatively new to SAS administration. I have installed SAS 9.3 in a Unix environment and also established connectivity with SQL Server. Now what I want to do is to customize SAS invocation command like below:-
SASt - Will connect to test server on SQL server
SASq - Will connect to QA server on SQL server
SASp - WIll connect to the SQL production server
Currently, I write ./sas to invoke SAS in my environment.
Any help in this matter will be greatly appreciated.
Let me know if additional information is needed.
Thanks in advance...
What exactly needs to change to connect to a different server? Do you need to run different SAS code? Set different environment variables? Set different SAS options? Set different SQL server options?
It might be that all you need is three dummy scripts that just do something and then call the existing script.
You might even be able to just make an alias if all you need to change is to add some command line switches.
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.