DATA Step, Macro, Functions and more

macro error

Reply
Contributor
Posts: 65

macro error

[ Edited ]

Hi,

 

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.


Capture.PNG
Super User
Super User
Posts: 7,401

Re: WARNING: The argument to macro function %SYSGET is not defined as a system variable.

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.

Contributor
Posts: 65

Re: WARNING: The argument to macro function %SYSGET is not defined as a system variable.

@RW9: Thanks for getting a clear understanding of the issue I am stuck with but could you please elaborate on how and what to put in the autoexec.sas file. I am a noob in this area. Your suggestions will be very helpful Smiley Happy
Super User
Super User
Posts: 7,401

Re: WARNING: The argument to macro function %SYSGET is not defined as a system variable.

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.

Super User
Posts: 6,936

Re: WARNING: The argument to macro function %SYSGET is not defined as a system variable.

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.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 65

Re: WARNING: The argument to macro function %SYSGET is not defined as a system variable.

Thank you so much @RW9, @KurtBremser. That makes it more clear.
Super User
Posts: 6,936

Re: WARNING: The argument to macro function %SYSGET is not defined as a system variable.

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"

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 65

Re: WARNING: The argument to macro function %SYSGET is not defined as a system variable.

@KurtBremser: Yeah that is a user defined macro.
Smiley Happy
Trusted Advisor
Posts: 1,115

Re: macro error

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.

Contributor
Posts: 65

Re: macro error

Thank you so much..that was a very silly error which was overlooked.

Ask a Question
Discussion stats
  • 9 replies
  • 765 views
  • 1 like
  • 4 in conversation