<?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: Programmatically finding a user's own repository in the SAS metadata repository in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Programmatically-finding-a-user-s-own-repository-in-the-SAS/m-p/987310#M380050</link>
    <description>&lt;P&gt;Find below some general code to list all project repositories and their owner.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 May 2026 17:36:38 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2026-05-05T17:36:38Z</dc:date>
    <item>
      <title>Programmatically finding a user's own repository in the SAS metadata repository</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Programmatically-finding-a-user-s-own-repository-in-the-SAS/m-p/987189#M380048</link>
      <description>&lt;P&gt;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&amp;nbsp;&lt;EM&gt;mostly&lt;/EM&gt; what I want to look at anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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&amp;nbsp;&lt;EM&gt;metadata_resolve&lt;/EM&gt;, but not quite.&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2026 22:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Programmatically-finding-a-user-s-own-repository-in-the-SAS/m-p/987189#M380048</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2026-05-04T22:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically finding a user's own repository in the SAS metadata repository</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Programmatically-finding-a-user-s-own-repository-in-the-SAS/m-p/987310#M380050</link>
      <description>&lt;P&gt;Find below some general code to list all project repositories and their owner.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 May 2026 17:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Programmatically-finding-a-user-s-own-repository-in-the-SAS/m-p/987310#M380050</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2026-05-05T17:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically finding a user's own repository in the SAS metadata repository</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Programmatically-finding-a-user-s-own-repository-in-the-SAS/m-p/987375#M380055</link>
      <description>&lt;P&gt;**bleep**, you're good! That's exactly what I needed.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2026 20:31:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Programmatically-finding-a-user-s-own-repository-in-the-SAS/m-p/987375#M380055</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2026-05-05T20:31:26Z</dc:date>
    </item>
  </channel>
</rss>

