Hi,
When I'm running the following program to list Metadata libraries, I don't get any results and any error either:
/*Connect to the metadata server. */ options metaserver="serveraddress.net" metaport=8561 metauser="sasadm" /* The domain-qualified user ID for the connection to */ /* the metadata server. */ metapass="*********" metarepository="Foundation"; /* Begin the query. The DATA statement names the output data set. */ data metadata_libraries; /* The LENGTH statement defines variables for function arguments and assigns the maximum length of each variable. */ length liburi upasnuri $256 name $128 type id $17 libref engine $8 path mdschemaname schema $256; /* The KEEP statement defines the variables to include in the output data set. */ keep name libref engine path mdschemaname schema; /* The CALL MISSING routine initializes the output variables to missing values. */ call missing(liburi,upasnuri,name,engine,libref); /* The METADATA_GETNOBJ function specifies to get the SASLibrary objects in the repository. The argument nlibobj=1 specifies to get the first object that matches the requested URI. liburi is an output variable. It will store the URI of the returned SASLibrary object. */ nlibobj=1; librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi); /* The DO statement specifies a group of statements to be executed as a unit for each object that is returned by METADATA_GETNOBJ. The METADATA_GETATTR function is used to retrieve the values of the Name, Engine, and Libref attributes of the SASLibrary object. */ do while (librc>0); /* Get Library attributes */ rc=metadata_getattr(liburi,'Name',name); rc=metadata_getattr(liburi,'Engine',engine); rc=metadata_getattr(liburi,'Libref',libref); /* The METADATA_GETNASN function specifies to get objects associated to the library via the UsingPackages association. The n argument specifies to return the first associated object for that association type. upasnuri is an output variable. It will store the URI of the associated metadata object, if one is found. */ n=1; uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri); /* When a UsingPackages association is found, the METADATA_RESOLVE function is called to resolve the URI to an object on the metadata server. The CALL MISSING routine assigns missing values to output variables. */ if uprc > 0 then do; call missing(type,id,path,mdschemaname,schema); rc=metadata_resolve(upasnuri,type,id); /* If type='Directory', the METADATA_GETATTR function is used to get its path and output the record */ if type='Directory' then do; rc=metadata_getattr(upasnuri,'DirectoryName',path); output; end; /* If type='DatabaseSchema', the METADATA_GETATTR function is used to get the name and schema, and output the record */ else if type='DatabaseSchema' then do; rc=metadata_getattr(upasnuri,'Name',mdschemaname); rc=metadata_getattr(upasnuri,'SchemaName',schema); output; end; /* Check to see if there are any more Directory objects */ n+1; uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri); end; /* if uprc > 0 */ /* Look for another library */ nlibobj+1; librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi); end; /* do while (librc>0) */ run; /* Print the metadata_libraries data set */ proc print data=metadata_libraries; run;
And here is the result: (attached file)
What could be the problem?
Thank you Resa,JuanS_OCS and Christian for your reply.
I did the changes and got no result. But we have two workspaces, one with LATIN encoding and the other one with UTF-8.
When I connected to the second one (UTF-8) I got results.
Hello @Riana,
whilst I would say this question is more for programmers than admins, I see also your point to bring the question here.
With the code, I cannot help you too much, but I will trust for starters it is OK.
I would propose you to check the logs and the metadata connection on the first lines:
options metaserver="serveraddress.net"
metaport=8561
metauser="sasadm" /* The domain-qualified user ID for the connection to */
/* the metadata server. */
metapass="*********"
metarepository="Foundation";
On one hand, the sasadm user does not seem right, I would use sasadm@saspw.
In other hand, it could also be that your connection details are not ok. If you are working with SAS Base, you could try a connection with "metabrowse;" and providing the connection details. Or to do the same with any other SAS client.
Thank you Juans_OCS for your reply.
Actually I edited the code otherwise I'm using sasadm@saspw in the original code.
I run the code in SAS EGuide.
Hi @Riana
I would opt for the suggestion made by @JuanS_OCS and try to use SAS Base and metabrowse to see whether all connection details are correct and/or whether all rights are ok.
I have just ran your code within EG and I did get a result (see attachment).
So IMHO your code seems to be fine.
Hi @Riana
You need to move the line below inside the do-loop.
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi);
nlibobj is your counter through the "list" of libraries (metadata-objects).
Hope it'll work 🙂
@Riana I was a bit too fast 😄
as @Resa and @JuanS_OCS are saying your code are fine! Sorry!
If you have access to the server you can get your connect options from here:
%include "E:\SAS\Config\Lev1\SASMeta\MetadataServer\metaparms.sas";
Thank you Resa,JuanS_OCS and Christian for your reply.
I did the changes and got no result. But we have two workspaces, one with LATIN encoding and the other one with UTF-8.
When I connected to the second one (UTF-8) I got results.
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.