Hi,
I've found a code snippet online to get most of what I require in regards to Report.BI Metadata properties, however, the code to get ResponsibleParty information was answered elsewhere in a separate context, and I can't cobble together the two pieces of code.
My issue is understanding how to utilise the metadata_getnasn
command and whether it's right to do so within the getnobj loop. The query does return two usernames based on my ask, but, it can return those 1...2...even 7 times over. Same record, just many duplicates.
Does anyone know (specifically regarding ResponsibleParties) how I obtain the creator/last modified names and dates, please?
data MDIDs (drop=_: label="SAS VA Report List");
length id $17 _uri name _name _modified _created location _location createdby modifiedby name person $256;
length created modified 8;
format created modified datetime19.;
_nobj=1;
_n=1;
call missing(id, _uri, _uri2, name, role, person, createdby, modifiedby, _name, _modified, _created, _location);
do while(_n le _nobj);
_nobj=metadata_getnobj("omsobj:Transformation?@PublicType = 'Report.BI'",_n,_uri);
_rc=metadata_getattr(_uri,"Id",id);
_rc=metadata_getattr(_uri,"Name",_name);
_rc=metadata_getattr(_uri,"MetadataCreated",_created);
_rc=metadata_getattr(_uri,"MetadataUpdated",_modified);
created=input(_created,anydtdtm.);
modified=input(_modified,anydtdtm.);
name=translate(translate(translate(translate(_name,"-","–"),"£","£"),"%","%"),"+","+");
/* Get creator / last modified. Doesn't work properly. */
passn=metadata_getnasn(_uri,"ResponsibleParties",1,Respuri);
_rc=metadata_getattr(Respuri, "Name", CreatedBy);
output;
passn=metadata_getnasn(_uri,"ResponsibleParties",2,Respuri);
_rc=metadata_getattr(Respuri, "Name", ModifiedBy);
output;
* Get folder object the current Report is in *;
_rc=metadata_getnasn(_uri,"Trees",1,_uri);
* Get folder name the current Report is in *;
_rc=metadata_getattr(_uri,"Name",location);
_tree=1;
* Loop up the folder hierarchy *;
do while (_tree>0);
* Get the parent folder object *;
_tree=metadata_getnasn(_uri,"ParentTree",1,_uri);
if _tree > 0 then do;
* If there was a parent folder, get the name *;
_rc=metadata_getattr(_uri,"Name",_location);
* Construct the path *;
location=catx('/',_location,location);
end;
end; * Folder Hierachy *;
location = '/'||location;
output;
_n=_n+1;
end;
run;
I've resolved this myself by using a working version of another piece of code (used for obtaining DI Job information) and injecting the same ResponsibleParty functions, which now works in this context.
data MDIDs;
length Server_Uri rp_uri Metadata_ID Name _Name TypeName Path Location _Location MetadataCreated MetadataUpdated CreatedBy ModifiedBy $256;
length Created Modified 8.;
format Created Modified datetime19.;
nobj = 1;
n=1;
call missing(Metadata_ID, _Name, MetadataCreated, MetadataUpdated, Created, Modified, TypeName, Path, Server_Uri, _location, CreatedBy, ModifiedBy);
do while(n le nobj);
nobj=metadata_getnobj("omsobj:Transformation?@PublicType = 'Report.BI'",n,Server_Uri);
rc=metadata_getattr(Server_Uri,'Id',Metadata_ID);
rc=metadata_getattr(Server_Uri,'Name',_Name);
rc=metadata_getattr(Server_Uri,"MetadataCreated",MetadataCreated);
rc=metadata_getattr(Server_Uri,"MetadataUpdated",MetadataUpdated);
name=translate(translate(translate(translate(_name,"-","–"),"£","£"),"%","%"),"+","+");
Created=input(MetadataCreated,anydtdtm.);
Modified=input(MetadataUpdated,anydtdtm.);
rc=metadata_getattr(Server_Uri,"PublicType",TypeName);
numrp=metadata_getnasn(Server_Uri,"ResponsibleParties",1,rp_uri);
if numrp>0 then do;
numrp=metadata_getnasn(Server_Uri,"ResponsibleParties",1,rp_uri);
rc=metadata_getattr(rp_uri,"name",CreatedBy);
numrp=metadata_getnasn(Server_Uri,"ResponsibleParties",2,rp_uri);
rc=metadata_getattr(rp_uri,"name",ModifiedBy);
end;
TreesCount=metadata_getnasn(Server_Uri,"Trees",1,Server_Uri);
rc=metadata_getattr(Server_Uri,"Name",Path);
_tree=1;
do while (_tree>0);
_tree=metadata_getnasn(Server_Uri,"ParentTree",1,Server_Uri);
if _tree > 0 then do;
_rc=metadata_getattr(Server_Uri,"Name",_location);
Path=catx('/',_location,Path);
end;
end;
Location = '/'||Path;
output;
n=n+1;
end;
keep Metadata_ID Name TypeName Location Created Modified CreatedBy ModifiedBy;
run;
I've resolved this myself by using a working version of another piece of code (used for obtaining DI Job information) and injecting the same ResponsibleParty functions, which now works in this context.
data MDIDs;
length Server_Uri rp_uri Metadata_ID Name _Name TypeName Path Location _Location MetadataCreated MetadataUpdated CreatedBy ModifiedBy $256;
length Created Modified 8.;
format Created Modified datetime19.;
nobj = 1;
n=1;
call missing(Metadata_ID, _Name, MetadataCreated, MetadataUpdated, Created, Modified, TypeName, Path, Server_Uri, _location, CreatedBy, ModifiedBy);
do while(n le nobj);
nobj=metadata_getnobj("omsobj:Transformation?@PublicType = 'Report.BI'",n,Server_Uri);
rc=metadata_getattr(Server_Uri,'Id',Metadata_ID);
rc=metadata_getattr(Server_Uri,'Name',_Name);
rc=metadata_getattr(Server_Uri,"MetadataCreated",MetadataCreated);
rc=metadata_getattr(Server_Uri,"MetadataUpdated",MetadataUpdated);
name=translate(translate(translate(translate(_name,"-","–"),"£","£"),"%","%"),"+","+");
Created=input(MetadataCreated,anydtdtm.);
Modified=input(MetadataUpdated,anydtdtm.);
rc=metadata_getattr(Server_Uri,"PublicType",TypeName);
numrp=metadata_getnasn(Server_Uri,"ResponsibleParties",1,rp_uri);
if numrp>0 then do;
numrp=metadata_getnasn(Server_Uri,"ResponsibleParties",1,rp_uri);
rc=metadata_getattr(rp_uri,"name",CreatedBy);
numrp=metadata_getnasn(Server_Uri,"ResponsibleParties",2,rp_uri);
rc=metadata_getattr(rp_uri,"name",ModifiedBy);
end;
TreesCount=metadata_getnasn(Server_Uri,"Trees",1,Server_Uri);
rc=metadata_getattr(Server_Uri,"Name",Path);
_tree=1;
do while (_tree>0);
_tree=metadata_getnasn(Server_Uri,"ParentTree",1,Server_Uri);
if _tree > 0 then do;
_rc=metadata_getattr(Server_Uri,"Name",_location);
Path=catx('/',_location,Path);
end;
end;
Location = '/'||Path;
output;
n=n+1;
end;
keep Metadata_ID Name TypeName Location Created Modified CreatedBy ModifiedBy;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.