I have a list of metadata objects from my repository. I've fetched all SASLibrary, PhysicalTable, Jobs objects. Now I need to fetch all their details. Can someone please suggest how can I do that? I am new to SAS DI and need to fetch the details using SAS code. Thanks
Asked
Active
Viewed 1,624 times
2 Answers
2
ok, assuming you have a dataset (have
) which contains those objects, and that the uri is stored in a variable called uri
then the following should suffice:
data associations;
keep assoc assocuri name;
length assoc assocuri name $256;
set have;
rc1=1;n1=1;
do while(rc1>0);
/* Walk through all possible associations of this object. */
rc1=metadata_getnasl(uri,n1,assoc);
rc2=1;n2=1;
do while(rc2>0);
/* Walk through all the associations on this machine object. */
rc2=metadata_getnasn(uri,trim(assoc),n2,assocuri);
if (rc2>0) then do;
rc3=metadata_getattr(assocuri,"Name",name);
output;
end;
call missing(name,assocuri);
put arc= rc2=;
n2+1;
end;
n1+1;
end;
run;
proc sort data=associations;
by assoc name;
run;
proc sql;
create table groupassoc as
select assoc, count(*) as cnt
from associations
group by 1;
data attrprop;
keep type name value;
length type $4 name $256 value $32767;
set have;
rc1=1;n1=1;type='Prop';
do while(rc1>0);
rc1=metadata_getnprp(uri,n1,name,value);
if rc1>0 then output;
n1+1;
end;
rc1=1;n1=1;type='Attr';
do while(rc1>0);
rc1=metadata_getnatr(uri,n1,name,value);
if rc1>0 then output;
n1+1;
end;
run;
proc sort data=attrprop;
by type name;
run;
This information can also be obtained using metabrowse
in Base SAS.

Allan Bowe
- 12,306
- 19
- 75
- 124
-
Thanks Allan. I'm not very familiar with metadata identifiers, but I reckon Metadata Id for every object is to be used as the URI. As you had suggested I used this code to get the metadata objects github.com/Boemska/macrocore/blob/master/meta/mm_getobjects.sas and renamed Id to URI. I used it to get obejcts for Physical tables, Sas Libraries and Jobs. Will the code help me get all the details like path for jobs/libraries/tables, and other attributes for all these types of objects? – Rhea May 11 '19 at 12:31
-
-
I tried the code but I did not get much details on the attribs, like the physical path, schema names,etc. I've posted a more explicit question here : https://stackoverflow.com/questions/56095004/sas-metadata-objects-details-saslibraries-physicaltables-jobs – Rhea May 11 '19 at 23:23
0
for example call this macro for metaobjects intereseting to you. The fullList table will contains all your interesting objects with metaId and object type:
options Metaport=portnumber;
options MetaUser="userid";
options Metapass="password";
options MetaServer="serverName";
options metaprotocol=bridge;
data fullList;
length objName $60 objId $17 objType $50;;
delete;
run;
%macro getMeta(objType);
data temp(keep=objType objName objId);
length uri $256 objName $60 objId $17 objType $50;
uri="";n=1;TableName="";
objType="&objType";
do while(metadata_getnobj("omsobj:&objType?@Id ? '.'",n,uri) >= 0);
rc=metadata_getattr(uri,"Name",objName);
rc=metadata_getattr(uri,"Id",objId);
n=n+1;
output;
end;
run;
proc append base=fullList data=temp;
run;
%mend;
%getMeta(Person);
%getMeta(PhysicalTable);
%getMeta(Job);
%getMeta(JFob);
.
.
. if you want .....

imnotarobot
- 131
- 4