- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.