BookmarkSubscribeRSS Feed
ashrivastava
Calcite | Level 5

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...

11 REPLIES 11
AnandVyas
Ammonite | Level 13

Hi @ashrivastava 

 

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. 

ashrivastava
Calcite | Level 5

Thanks for the suggestion. Could you please explain a bit more about this wrapper script?

alexal
SAS Employee

@ashrivastava ,

 

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
AnandVyas
Ammonite | Level 13
Do you use a single odbc.ini to setup all 3 sqlsrvr data sources or separate files?
ashrivastava
Calcite | Level 5

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!!

AnandVyas
Ammonite | Level 13
Thanks for sharing the old script. What does LIBPATH is pointing to in sub.profile file? I think it's the libname statement?
ashrivastava
Calcite | Level 5

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.

AnandVyas
Ammonite | Level 13
In this scenario, he will have to use sasbatch.sh for the configurations to load for separate app contexts. If sas binary is directly launched from foundation directory, those configurations won't be read during session launch.
ashrivastava
Calcite | Level 5

We don't want to set up multiple servers.

Tom
Super User Tom
Super User

@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.

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 

Get Started with SAS Information Catalog in SAS Viya

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.

Discussion stats
  • 11 replies
  • 1740 views
  • 2 likes
  • 5 in conversation