BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
LaurieF
Barite | Level 11

I have a lot of code which trawls through the metadata repository to find, well, all sorts of useful stuff: tables, columns, dependencies, transformation templates - that sort of thing. But it only works reliably on the Foundation repository - which is mostly what I want to look at anyway.

 

But I'm introducing a new facility for other developers to be able to look at the results of jobs, and for that the code needs to look at the developer's own repository - what they've checked out in DI, for example. How can I work out from the datastep metadata functions what repository they're using? Not all repository ids map on to userids, unfortunately. I'm most of the way there with metadata_resolve, but not quite.

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Find below some general code to list all project repositories and their owner. 

 

data md_project_repo_owner;
  length
    nRep 8
    type etype $ 32
    id eId $ 32
    repSearch $ 128
    repURI $ 128
    repName $ 128
    repPath $ 1024
    extSearch $ 1024
    ownerURI $ 128
    ownerId $ 64
  ;
  call missing(type, etype, id, eid, repSearch, repURI, repName, repPath, extSearch, ownerURI);


  * 
  * search for Project repositories
  *;
  repSearch = "OMSOBJ:Repository?@RepositoryType = 'Project'";
  nRep = metadata_resolve(repSearch, type, id);
  putlog "NOTE: Number of Objects found for" +1 repSearch= nRep=;

  *
  * get the individual repURI for each entry
  *;
  do objN = 1 to nRep;
    rc = metadata_getnobj(repSearch, objN, repURI);
    *
    * get Object type and id from objURI
    *;
    eObjType = scan(repURI, 2, ":\");
    eObjId = scan(repURI, 2, "\");

    *
    * get repository details
    * more attributes are available
    *;
    rc = metadata_getattr(repURI, "Name", repName);
    rc = metadata_getattr(repURI, "Path", repPath);

    *
    * search Extension objects
    *;
    extSearch = cats("OMSOBJ:Extension?@Name='ProjectRepository' and @Value=", quote(strip(eObjId), "'"));
    nExt = metadata_resolve(extSearch, etype, eid);

    *
    * get the owner object
    *;
    rc = metadata_getnasn(eId, "OwningObject", 1, ownerURI);

    *
    * get owner id
    *;
    rc = metadata_getattr(ownerURI, "Name", ownerId); 
    output;
  end;
  keep repURI repName repPath ownerURI ownerId;
run;

View solution in original post

2 REPLIES 2
BrunoMueller
SAS Super FREQ

Find below some general code to list all project repositories and their owner. 

 

data md_project_repo_owner;
  length
    nRep 8
    type etype $ 32
    id eId $ 32
    repSearch $ 128
    repURI $ 128
    repName $ 128
    repPath $ 1024
    extSearch $ 1024
    ownerURI $ 128
    ownerId $ 64
  ;
  call missing(type, etype, id, eid, repSearch, repURI, repName, repPath, extSearch, ownerURI);


  * 
  * search for Project repositories
  *;
  repSearch = "OMSOBJ:Repository?@RepositoryType = 'Project'";
  nRep = metadata_resolve(repSearch, type, id);
  putlog "NOTE: Number of Objects found for" +1 repSearch= nRep=;

  *
  * get the individual repURI for each entry
  *;
  do objN = 1 to nRep;
    rc = metadata_getnobj(repSearch, objN, repURI);
    *
    * get Object type and id from objURI
    *;
    eObjType = scan(repURI, 2, ":\");
    eObjId = scan(repURI, 2, "\");

    *
    * get repository details
    * more attributes are available
    *;
    rc = metadata_getattr(repURI, "Name", repName);
    rc = metadata_getattr(repURI, "Path", repPath);

    *
    * search Extension objects
    *;
    extSearch = cats("OMSOBJ:Extension?@Name='ProjectRepository' and @Value=", quote(strip(eObjId), "'"));
    nExt = metadata_resolve(extSearch, etype, eid);

    *
    * get the owner object
    *;
    rc = metadata_getnasn(eId, "OwningObject", 1, ownerURI);

    *
    * get owner id
    *;
    rc = metadata_getattr(ownerURI, "Name", ownerId); 
    output;
  end;
  keep repURI repName repPath ownerURI ownerId;
run;
LaurieF
Barite | Level 11

**bleep**, you're good! That's exactly what I needed.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore 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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 281 views
  • 2 likes
  • 2 in conversation