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;
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
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.
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.
You need to use &sysuserid
Just be careful about token authentication. In some environments %sysuserid might resolve to sassrv for everyone.
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
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
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
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.