BookmarkSubscribeRSS Feed
metalray
Calcite | Level 5
Hi Guys,
I want to build a SQL that goes to an Oracle View that is executed in various ways depending on the SAS user groups.
Now, I found this piece of code that gets me all users names togehter with IDs and their groups. nice. but I only want to get the user groups of the user that is executing the STP (as part of a web report). could someone help because I am uncertain if in this case _metauser will do the trick or not.

data users_grps;
length uri name group groupuri $256 id $20;

/* Initialize variables to missing. */
n=1;
uri='';
name='';
group='';
groupuri='';
id='';

*Determine how many person objects are defined.;
nobj=metadata_getnobj("omsobj:Person?@Id contains '.'",n,uri);
if nobj=0 then put 'No Persons available.';

else do while (nobj > 0);

/* Retrieve the current person's name. */
rc=metadata_getattr(uri, "Name", Name);

/* Get the group association information for the current person. */
a=1;
grpassn=metadata_getnasn(uri,"IdentityGroups",a,groupuri);

/* If this person does not belong to any groups, set their group */
/* variable to 'No groups' and output the name. */
if grpassn in (-3,-4) then do;
group="No groups";
output;
end;

/* If the person belongs to any groups, loop through the list */
/* and retrieve the name of each group, outputting each on a */
/* separate record. */
else do while (grpassn > 0);
rc2=metadata_getattr(groupuri, "Name", group);
a+1;
output;
grpassn=metadata_getnasn(uri,"IdentityGroups",a,groupuri);
end;

/* Retrieve the next person's information. */
n+1;
nobj=metadata_getnobj("omsobj:Person?@Id contains '.'",n,uri);
end;
keep name group;
run;
2 REPLIES 2
metalray
Calcite | Level 5
the stp is actually in an information map. so the current executor of the stp->information map -> web report is what I am looking for . I have done the same thing with PROC OLAP and in that case its enough to "just" write a connection string without any user credentials.
but know I actually need it in the code to have a IF---ELSE and use the "correct" proc sql depending on the user group(s).

it is not the groups yet but just the username:
%let uid_var=corp\%sysfunc(scan(“&_METAUSER”,1,“@”)));
WARNING: Apparent symbolic reference _METAUSER not resolved.
metalray
Calcite | Level 5
It would be great if I could use SAS.IdentityGroups in the STP.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 894 views
  • 0 likes
  • 1 in conversation