BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Fiachra
Fluorite | Level 6

Hi guys,

 

I have the following line of code in the E:\SAS\Config\Lev1\SASApp\appserver_autoexec_usermods.sas file which is used to assign macro search and format libraries 

 

options compress=yes MAUTOSOURCE SASAUTOS=("E:\SASData\HPO\MACROS") FMTSEARCH=(WORK FORMATS APFMTLIB);

 

This works fine and the formats are accessible from EG.

 

However I would like to assign these searches  conditionally based on the userid and I tried the code below. The code works fine if I run it directly in EG but when I have it in E:\SAS\Config\Lev1\SASApp\appserver_autoexec_usermods.sas the formats are not accessible. 

 

This is all on the workspace server rather than stored process. Within EG it looks as though the conditions to make the assignments as per the %else %if are being met but not in the autoexec. Is there somewhere I can view the log to see what is happening here? Is there a fundamental reason why this wouldn't work?

 

Any Help welcome. Thanks.

 

 

%macro setfmt();


%if %upcase(&_clientuserid)='USER1' or %upcase(&_clientuserid)='USER2' %then %do;

options compress=yes MAUTOSOURCE SASAUTOS=("E:\SASData\QID\QID_MAC") FMTSEARCH=(WORK QID_FMT APFMTLIB);

%end;

%else %do;

options compress=yes MAUTOSOURCE SASAUTOS=("E:\SASData\HPO\MACROS") FMTSEARCH=(WORK FORMATS APFMTLIB);

%end;

%mend;

%setfmt;

1 ACCEPTED SOLUTION

Accepted Solutions
Fiachra
Fluorite | Level 6

Hi guys,

 

Thanks for the very useful suggestions. Using &sasuserid has solved my issue and the correct paths and libraries are now being set.

 

Thanks for the help.

 

Fiachra

View solution in original post

6 REPLIES 6
JackHamilton
Lapis Lazuli | Level 10
Here, and so probably also at your site, _CLIENTUSERID is set to, e.g. 'USER1' in EG, but to USER1 (no quotes) in SAS Studio. Seems like an odd inconsistency, but there it is. Different ways of starting a session may result in yet another way the value is set.
Will &SYSUSERID. instead of _CLIENTUSERID work for you? I think it will if you're not running on the Stored Process Server, but I haven't tried it.


Fiachra
Fluorite | Level 6

Hi Jack,

 

Thanks for the suggestion. I tried removing the quotes but it didn't make any difference. At the moment I am trying to get the default branch to work i.e. the %else %if piece which is the one relevant to my own account  (neither USER1 or USER2) so I would have thought the code would be executed with or without the quotes. Seems not to be the case though.

 

I just tried replacing the first conditional statement with

 

%if 1=2 or 2=3 %then %do;

options......

%end;

 

and the assignment works fine so the issue is with the initial if statement which seems to be returning  true even though neither of the users specified is me.

SASKiwi
PROC Star

You need to use &sysuserid not &_CLIENTUSERID in server autoexecs as &_CLIENTUSERID is an EG only addition. &sysuserid is your user account without quotes so your macro logic should not include quotes. 

SimonDawson
SAS Employee

You need to use &sysuserid

Just be careful about token authentication. In some environments %sysuserid might resolve to sassrv for everyone.

Fiachra
Fluorite | Level 6

Hi guys,

 

Thanks for the very useful suggestions. Using &sasuserid has solved my issue and the correct paths and libraries are now being set.

 

Thanks for the help.

 

Fiachra

AndreasWindisch
Obsidian | Level 7

Hey Folks,

 

just a @SimonDawson mentioned you have to be aware of the Token Authentication.
I just had to prepare the environment for different Application Server Context in the same Installation.
The solution was a site - specific autoexec which is included in the autoexec_usermods of the Application Server Context which will  need it.

 

In my case i could work with the token user, so i first check the existence of the &SYSUSERID variable...

%macro appsercontext_XYZ / des='Macro for assign options per application server context XYZ';
    %if %symexist(SYSUSERID) %then
        %do;
            %*Identify the SYSUSERID for the application server context;
            %if %index(%upcase(&SYSUSERID),<inser token user>) %then
                %do;
                    /*Options block*/
                    options nosource;
                    options compress=yes MAUTOSOURCE SASAUTOS=("E:\SASData\QID\QID_MAC") FMTSEARCH=(WORK QID_FMT APFMTLIB);
                    options source;
                %end;
        %end;
    %else %do;
        /*Options block*/
        options nosource;
        options compress=yes MAUTOSOURCE SASAUTOS=("E:\SASData\HPO\MACROS") FMTSEARCH=(WORK FORMATS APFMTLIB);
        options source;
    %end;
%mend;

 

 

Best regards,
Andreas

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
  • 6 replies
  • 1868 views
  • 3 likes
  • 5 in conversation