BookmarkSubscribeRSS Feed
Lethics
Calcite | Level 5
Hello,

I'm trying to make a function to get the identityGroups of my users with recursion because I want to know the IdentityGroup of my group ...etc.

Here is a sample :
options metaserver="Tiger"
metarepository="Foundation"
metaport=8563
metaprotocol=bridge
metauser="sasadm"
metapass="XXXXXXXXXX";
/********************************************************************************************/
/* GET_USER : */
/* ALLOW TO RETRIEVE FROM METADATA THE UID OF THE USER OBJECT BASED ON THE LOGIN */
/********************************************************************************************/
%global UserUID;
%MACRO GET_USER(user);
data info_user (keep= person_id name login );
length person_id uri newuri login name $256;
length Nobj rc imax 8.;
/* TO GET ALL PERSON IN THE METADATA*/
Nobj = Metadata_GetNobj("OMSOBJ:Person?@id contains '.'",1,uri);
DO j = 1 TO Nobj;
/* GET THE JTH PERSON */
rc = Metadata_GetNobj("OMSOBJ:Person?@id contains '.'",j,uri);
/* GET ID OF THE CURRENT PERSON */
rc = Metadata_GetAttr(uri,"id",person_id);
rc = Metadata_GetAttr(uri,"Name",Name);
/* GET THE RELATED LOGIN OF THE CURRENT OBJECT */
rc = Metadata_getnasn(catx(":","OMSOBJ",person_id),"Logins",1,newuri);
/* GET USERID IN LOGIN */
rc = Metadata_GetAttr(newuri,"UserID",login);
If login = "&user" then
DO ;
j = Nobj;
END;
END;
call symput('UserUID',person_id);
run;
%MEND;

%GET_USER(jnr);
proc fcmp outlib=work.funcs.myfuncs;
subroutine getGroup( id$ );
nbGroup = Metadata_Getnasn(catx(":","OMSOBJ",id),"IdentityGroups",1,GroupUri);
put nbGroup=;
/*DO i = 1 TO nbGroup;
tmp = catx(":","OMSOBJ",id);
rc = %sysfunc(Metadata_Getnasn(tmp,"IdentityGroups",i,GroupUri));
rc = %sysfunc(Metadata_Getattr(GroupUri,"Name",Name));
rc = %sysfunc(Metadata_Getattr(GroupUri,"Id",Id2));
tmp = catx(":","OMSOBJ",id2);
rc = %sysfunc(Metadata_Getnasn(tmp,"IdentityGroups",1,GroupUri2));
output;
if rc > 0 then
call GetGroup(ID2);
END;*/
endsub;
quit;

options cmplib=work.funcs;

DATA Group_user (keep= Name Id nbChild);
LENGTH tmp GroupUri GroupUri2 Name Id $256.;
LENGTH nbGroup 8.;
call GetGroup("&UserUID");

RUN;

Using Metadata_ in %sysfunc() always return -3.

Is it possible to use this kind of functions in FCMP ?

Regards from Belgium.

EDIT :

SAS support :
This is a known bug, The problem is that CMP fails to recognize SAS functions with 16 Character names.
Research and Development have fixed this problem in 9.2 Maintenance 3.

Our latest version shipping of SAS 9.2 is maintenance 2. SAS 9.2 Maintenance 3 is scheduled for release in May of 2010. This date is not guaranteed and may change. Message was edited by: Lethics
1 REPLY 1
Patrick
Opal | Level 21
Thanks for sharing the resolution.

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
  • 1 reply
  • 915 views
  • 0 likes
  • 2 in conversation