BookmarkSubscribeRSS Feed
Jumboshrimps
Quartz | Level 8

Have two servers - PROD & TEST.  I often flip between developing on TEST, and running production code on PROD on PC SAS 9.4

Signon is done at the top of the code as below.                                                                                                                                                                                                                                                                           

OPTIONS netencralg=SASProprietary;                                                                                                                                              
OPTIONS COMAMID= tcp remote                                                                                                                                                                                    

Enter my credentials  - same for PROD and TEST                                                                                                               

I can alter data all day long on TEST, but not PROD, of course. Should I mix those two up, that would a problem.  Lib names are exactly the same for both.

I decided to write a short macro and place it in the SAS startup directory. thinking I would run the macro before any long code that updates data sets.                                                                                                                                                 

 

%macro server;

%if &mynode = 'longstringofletters_numbers'
%then

%put ' TEST Server';
%else
%put ' PROD Server';

%mend;

 

I use %put &mynode, which displays the server name.  I then cut-and-paste that into the macro.

Result always defaults to PROD, even though the string for the server is TEST.

                                                                                                                                                                                

I tried to use like instead of "=", but I get the following error:

 A character operand was found in the %EVAL function or %IF condition where a numeric
operand is required.

 

There are no special characters in server name.  Used the "%" in the beginning and end of the server name, did not  help.

Where did I go wrong?

 

1 REPLY 1
Quentin
Super User

If the value of &mynote is a lon string of letters and numbers without quotation marks around them, then you don't want quotation marks around the value on your %IF statement.  The macro language does not use quotation marks to indicate text values, because every value is a text value in the macro language.  Similarly, you don't need quotation marks on your %PUT statements.  Try:

 

%macro server;

  %if &mynode = longstringofletters_numbers
  %then
  %put TEST Server;
  %else
  %put PROD Server;

%mend;
The Boston Area SAS Users Group is hosting free webinars!
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 325 views
  • 0 likes
  • 2 in conversation