<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use Metadata_ in user function (FCMP) [SOLVED] in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-Metadata-in-user-function-FCMP-SOLVED/m-p/75416#M16248</link>
    <description>Thanks for sharing the resolution.</description>
    <pubDate>Wed, 21 Apr 2010 00:37:55 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2010-04-21T00:37:55Z</dc:date>
    <item>
      <title>How to use Metadata_ in user function (FCMP) [SOLVED]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-Metadata-in-user-function-FCMP-SOLVED/m-p/75415#M16247</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
Here is a sample :&lt;BR /&gt;
options metaserver="Tiger"&lt;BR /&gt;
    metarepository="Foundation"&lt;BR /&gt;
	metaport=8563&lt;BR /&gt;
	metaprotocol=bridge&lt;BR /&gt;
	metauser="sasadm"&lt;BR /&gt;
	metapass="XXXXXXXXXX";&lt;BR /&gt;
/********************************************************************************************/&lt;BR /&gt;
/* GET_USER :																				*/&lt;BR /&gt;
/*		ALLOW TO RETRIEVE FROM METADATA THE UID OF THE USER OBJECT BASED ON THE LOGIN		*/&lt;BR /&gt;
/********************************************************************************************/&lt;BR /&gt;
%global UserUID;&lt;BR /&gt;
%MACRO GET_USER(user);&lt;BR /&gt;
data info_user (keep= person_id name login );&lt;BR /&gt;
	length person_id uri  newuri login name $256;&lt;BR /&gt;
	length Nobj rc imax 8.;&lt;BR /&gt;
	/* TO GET ALL PERSON IN THE METADATA*/&lt;BR /&gt;
	Nobj = Metadata_GetNobj("OMSOBJ:Person?@id contains '.'",1,uri);&lt;BR /&gt;
	DO j = 1 TO Nobj;&lt;BR /&gt;
		/* GET THE JTH PERSON */&lt;BR /&gt;
			rc = Metadata_GetNobj("OMSOBJ:Person?@id contains '.'",j,uri);&lt;BR /&gt;
		/* GET ID OF THE CURRENT PERSON */&lt;BR /&gt;
			rc = Metadata_GetAttr(uri,"id",person_id);&lt;BR /&gt;
			rc = Metadata_GetAttr(uri,"Name",Name);&lt;BR /&gt;
		/* GET THE RELATED LOGIN OF THE CURRENT OBJECT */&lt;BR /&gt;
			rc = Metadata_getnasn(catx(":","OMSOBJ",person_id),"Logins",1,newuri);&lt;BR /&gt;
		/* GET USERID IN LOGIN */&lt;BR /&gt;
			rc = Metadata_GetAttr(newuri,"UserID",login);&lt;BR /&gt;
		If login = "&amp;amp;user" then &lt;BR /&gt;
			DO ;	&lt;BR /&gt;
				j = Nobj;&lt;BR /&gt;
			END;&lt;BR /&gt;
	END;&lt;BR /&gt;
	call symput('UserUID',person_id);&lt;BR /&gt;
run;&lt;BR /&gt;
%MEND;&lt;BR /&gt;
&lt;BR /&gt;
%GET_USER(jnr);&lt;BR /&gt;
proc fcmp outlib=work.funcs.myfuncs;&lt;BR /&gt;
	subroutine getGroup( id$ );&lt;BR /&gt;
		nbGroup = Metadata_Getnasn(catx(":","OMSOBJ",id),"IdentityGroups",1,GroupUri);&lt;BR /&gt;
		put nbGroup=;&lt;BR /&gt;
	/*DO i = 1 TO nbGroup;&lt;BR /&gt;
		tmp = catx(":","OMSOBJ",id);&lt;BR /&gt;
		rc = %sysfunc(Metadata_Getnasn(tmp,"IdentityGroups",i,GroupUri));&lt;BR /&gt;
		rc = %sysfunc(Metadata_Getattr(GroupUri,"Name",Name));&lt;BR /&gt;
		rc = %sysfunc(Metadata_Getattr(GroupUri,"Id",Id2));&lt;BR /&gt;
		tmp = catx(":","OMSOBJ",id2);&lt;BR /&gt;
		rc = %sysfunc(Metadata_Getnasn(tmp,"IdentityGroups",1,GroupUri2));&lt;BR /&gt;
		output;&lt;BR /&gt;
		if rc &amp;gt; 0 then&lt;BR /&gt;
			call GetGroup(ID2);&lt;BR /&gt;
	END;*/&lt;BR /&gt;
	endsub;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
options cmplib=work.funcs;&lt;BR /&gt;
&lt;BR /&gt;
DATA Group_user (keep= Name Id nbChild);&lt;BR /&gt;
	LENGTH tmp GroupUri GroupUri2 Name Id $256.;&lt;BR /&gt;
	LENGTH  nbGroup 8.;&lt;BR /&gt;
	call GetGroup("&amp;amp;UserUID");&lt;BR /&gt;
	&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
Using Metadata_ in %sysfunc() always return -3.&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to use this kind of functions in FCMP ?&lt;BR /&gt;
&lt;BR /&gt;
Regards from Belgium.&lt;BR /&gt;
&lt;BR /&gt;
EDIT :&lt;BR /&gt;
&lt;BR /&gt;
SAS support : &lt;BR /&gt;
This is a known bug, The problem is that CMP fails to recognize SAS functions with 16 Character names. &lt;BR /&gt;
Research and Development have fixed this problem in 9.2 Maintenance 3. &lt;BR /&gt;
&lt;BR /&gt;
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</description>
      <pubDate>Thu, 15 Apr 2010 09:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-Metadata-in-user-function-FCMP-SOLVED/m-p/75415#M16247</guid>
      <dc:creator>Lethics</dc:creator>
      <dc:date>2010-04-15T09:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Metadata_ in user function (FCMP) [SOLVED]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-Metadata-in-user-function-FCMP-SOLVED/m-p/75416#M16248</link>
      <description>Thanks for sharing the resolution.</description>
      <pubDate>Wed, 21 Apr 2010 00:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-Metadata-in-user-function-FCMP-SOLVED/m-p/75416#M16248</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-04-21T00:37:55Z</dc:date>
    </item>
  </channel>
</rss>

