<?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: GetMetata - How to filter response XML in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/GetMetata-How-to-filter-response-XML/m-p/605006#M18427</link>
    <description>&lt;P&gt;Patrick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; There are several ways to do this.&amp;nbsp; You could try an XMLMap and map the data.&amp;nbsp; You could change the Get metadata to only get the fields you want.&amp;nbsp; like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;metadata&lt;/SPAN&gt;
   &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;myinput
   out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;myoutput (keep=xxxxx, yyyyy)&lt;SPAN class="token punctuation"&gt;; &lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You could read the XML back into a SAS dataset and then do what you want to it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="codeFragment"&gt;libname jobs xml '/data/jobs.xml';

proc datasets library=jobs;
run;&lt;BR /&gt;proc ..... &lt;/PRE&gt;
&lt;P&gt;There are some nice examples here:&amp;nbsp; &lt;A href="https://go.documentation.sas.com/api/docsets/lrmeta/9.4/content/lrmeta.pdf" target="_blank"&gt;https://go.documentation.sas.com/api/docsets/lrmeta/9.4/content/lrmeta.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Andy&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Nov 2019 14:01:24 GMT</pubDate>
    <dc:creator>Andy547</dc:creator>
    <dc:date>2019-11-18T14:01:24Z</dc:date>
    <item>
      <title>GetMetata - How to filter response XML</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/GetMetata-How-to-filter-response-XML/m-p/604678#M18415</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've got a working Metadata query (code below) but I can't manage to define a filter so that the respond XML contains less information.&lt;/P&gt;
&lt;P&gt;The working query is here.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename myinput temp lrecl=256;
filename myoutput '~/test.xml' lrecl=256;
/*filename myoutput temp lrecl=256;*/

data _null_;
   file myinput;
   input;
   put _infile_ ' ';
   datalines;
&amp;lt;GetMetadata&amp;gt;
 &amp;lt;Metadata&amp;gt;
   &amp;lt;Job Id="A5LSNX1U.BU0001H8"/&amp;gt;
 &amp;lt;/Metadata&amp;gt;
 &amp;lt;NS&amp;gt;SAS&amp;lt;/NS&amp;gt;
 &amp;lt;!--OMI Flags 1 + 2 + 2048 --&amp;gt;
 &amp;lt;Flags&amp;gt;2051&amp;lt;/Flags&amp;gt;
 &amp;lt;Options/&amp;gt;
&amp;lt;/GetMetadata&amp;gt;

;
run;

proc metadata
   in=myinput
   out=myoutput;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The only information I really need per Job:&lt;/P&gt;
&lt;P&gt;All TextStore objects with attributes ID and StoreText.&lt;/P&gt;
&lt;P&gt;Example:&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&amp;lt;TextStore Id="A5LSNX1U.AG0007ZF" StoredText="%inc 'path user written';" /&amp;gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Context&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I'm working on a large migration project with lots of DIS jobs who use a lot of user written code with fully hard coded paths (don't ask!).&lt;/P&gt;
&lt;P&gt;Some of the paths will have to change in the target environment (and no, we can't keep them the same using symlinks).&lt;/P&gt;
&lt;P&gt;Environment is Rhel both source and target. SAS version is from source 9.4 to target 9.4 (latest maintenance release).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm trying to do:&lt;/P&gt;
&lt;P&gt;1. Pull out all the user written hard coded paths from the source metadata environment&lt;/P&gt;
&lt;P&gt;2. Manually create a mapping sheet source path to target path (where paths change)&lt;/P&gt;
&lt;P&gt;3. Write code which uses this mapping sheet and changes the user written paths in target Metadata after .spk's have been imported into the target environment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm currently working on step 1. I could make things work with what I have already but it would help if I could reduce the size of the response XML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here the same query using the SMC XML Metadata Interface&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34021iA4BBFFBFA9E03A34/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2019 10:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/GetMetata-How-to-filter-response-XML/m-p/604678#M18415</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-11-16T10:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: GetMetata - How to filter response XML</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/GetMetata-How-to-filter-response-XML/m-p/605006#M18427</link>
      <description>&lt;P&gt;Patrick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; There are several ways to do this.&amp;nbsp; You could try an XMLMap and map the data.&amp;nbsp; You could change the Get metadata to only get the fields you want.&amp;nbsp; like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;metadata&lt;/SPAN&gt;
   &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;myinput
   out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;myoutput (keep=xxxxx, yyyyy)&lt;SPAN class="token punctuation"&gt;; &lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You could read the XML back into a SAS dataset and then do what you want to it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="codeFragment"&gt;libname jobs xml '/data/jobs.xml';

proc datasets library=jobs;
run;&lt;BR /&gt;proc ..... &lt;/PRE&gt;
&lt;P&gt;There are some nice examples here:&amp;nbsp; &lt;A href="https://go.documentation.sas.com/api/docsets/lrmeta/9.4/content/lrmeta.pdf" target="_blank"&gt;https://go.documentation.sas.com/api/docsets/lrmeta/9.4/content/lrmeta.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Andy&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/GetMetata-How-to-filter-response-XML/m-p/605006#M18427</guid>
      <dc:creator>Andy547</dc:creator>
      <dc:date>2019-11-18T14:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: GetMetata - How to filter response XML</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/GetMetata-How-to-filter-response-XML/m-p/605149#M18428</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/70637"&gt;@Andy547&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you propose is what I'm currently doing. I use an XML map and read the response XML into SAS tables, I then select the tables with the info I need (TextStore, TextStore1, TextStore&amp;lt;n&amp;gt;).&lt;/P&gt;
&lt;P&gt;What I'm after is a request XML that returns a smaller response XML/less data. I've also consulted the docu you've posted but I didn't manage to define such a request XML.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 18:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/GetMetata-How-to-filter-response-XML/m-p/605149#M18428</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-11-18T18:50:37Z</dc:date>
    </item>
  </channel>
</rss>

