01-21-2016 04:37 AM - edited 01-21-2016 08:18 AM
I have SAS 9.1.3 , 9.3 and 9.4(all three of them) installed on my Unix server. So I have an application which is used to submit batch programs to the remote SAS. Also, I can signon to any of the three versions and submit a batch to any of the three SAS version on the same UNIX server. To choose the version I want to sumbit my batch on, I have given a radiobox control which has which has 3 radio buttons(See attached).
To get the above submission, I am using the following code:-
/* macro "sysver" gives the version of SAS currently connected to and sasver refers to the server I
want to submit batch on, based on which certain flags are getting modified*/ %if "&sysver"="9.1" and "&sasver"="sas93" or "&sasver"="sas94" %then %let flag_reset=1; %else %if "&sysver"="9.3" or "&sysver"="9.4" and "&sasver"="sas" %then %let flag_reset=2; %else %let flag_reset=0; /* To submit batch from a lower version to higher, I am including TKPATH variable and assigning
it an empty string which will be later set to the tkpath*/ %if &flag_reset=1 %then %do; %let tkpath=%sysget(TKPATH) ; options set=TKPATH "" ; %end;
So when I am signed on to SAS 9.3 or 9.4,I am getting a warning message as below:-
WARNING: The argument to macro function %SYSGET is not defined as a system variable.
Even if the statment (below) is inside a conditional construct which is never getting executed, it is prompting me the above warning message.
%let tkpath=%sysget(TKPATH) ;
Please suggest a method to either remediate this or get rid of the warning message.
01-21-2016 04:53 AM
Macro language is a code generation system. It is always run, and always decomipled. Basically the preprocessor is trying to sort out all the references before trying conditionals. I would ask why your trying to do things this way. Every version of SAS can have its own confirguration setup - autoexec.sas - which gets called when the SAS system starts up - in batch that can be in the same folder as the program, or on the install area. This kind of setup code would be far better suited to be put in the setup autoexec.sas file for the individual installs, then you don't need to worry about all the code below or try to replicate what that is doing, you just add the necessary code into each autoexec.sas.
01-21-2016 05:10 AM
01-21-2016 05:13 AM
This depends on your setup/install. You would need to check with your IT group where/how they have set it up. Its called autoexec.sas, and if you run something in batch (if installed locally) then the autoexec can reside in the same directory, or it could be on the network drive that SAS is installed on. Speak to whoever installed it, they should be able to show you where the install is and then you will see this file.
01-21-2016 06:08 AM
autoexec.sas is a simple text file containing Base SAS code. So everything that works in a code window in EG or SAS Studio will work there.
Code that needs to be done anytime a SAS session or batch job is started, should go in there.
Depending on your setup, you can either use a (or the) global autoexec.sas, or you might be better off modifying a autoexec_usermods.sas file in your configuration path on the server.
01-21-2016 06:15 AM
I also suspect you have a typo in there, as &sasver is not a defined automatic macro variable.
Which makes me question the purpose of
%if "&sysver"="9.1" and "&sasver"="sas93" or "&sasver"="sas94"
01-21-2016 09:32 AM
On my Windows machine, I cannot replicate the warning message if the %LET statement using the %SYSGET function is not executed (because the %IF condition is not met). I conclude, that it is executed in your case when you receive the warning message.
As the reason I suspect incorrect logic: Please note that your condition
"&sysver"="9.1" and "&sasver"="sas93" or "&sasver"="sas94"
could be rewritten as
("&sysver"="9.1" and "&sasver"="sas93") or "&sasver"="sas94"
but it seems more plausible to me that it should read
"&sysver"="9.1" and ("&sasver"="sas93" or "&sasver"="sas94")
And similarly for the other condition
"&sysver"="9.3" or "&sysver"="9.4" and "&sasver"="sas"
So, I would try to insert parentheses at the appropriate places.