<?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: sas proc sql pass through xml in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/sas-proc-sql-pass-through-xml/m-p/218103#M53627</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for reply. I am sure your method would work out, but I feel there should be a more xml-like way to do the job.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 May 2015 18:36:30 GMT</pubDate>
    <dc:creator>abcd123</dc:creator>
    <dc:date>2015-05-21T18:36:30Z</dc:date>
    <item>
      <title>sas proc sql pass through xml</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-proc-sql-pass-through-xml/m-p/218101#M53625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using proc sql pass through to extract xml data from a db2 server, the query looks like following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;select&amp;nbsp; xmlquery('data($DATA/*:annotation/*:EventStart/@data)') as MyData&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;from db2server&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The returned data is like following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;lt;?xml version="1.0" encoding="windows-1252" ?&amp;gt;1234567&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But all I need is the numeric part, i.e., 1234567. How to remove the leading &lt;SPAN style="color: #ff0000;"&gt;&amp;lt;?xml version="1.0" encoding="windows-1252" ?&amp;gt;&lt;/SPAN&gt;?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 16:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-proc-sql-pass-through-xml/m-p/218101#M53625</guid>
      <dc:creator>abcd123</dc:creator>
      <dc:date>2015-05-21T16:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: sas proc sql pass through xml</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-proc-sql-pass-through-xml/m-p/218102#M53626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use the TRANSTRN function to simply remove your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aka something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;newstring=strip(Transtrn(oldvar,'&amp;lt;?xml version="1.0" encoding="windows-1252" ?&amp;gt;',''))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of if you cannot guarantee that hte first section will always have this exact wording, you could simply substring the results starting at the first end position of &amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aka something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Newstring=substr(oldstring,find(oldstring,'&amp;gt;')+1,length(oldstring));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note I didn't test either of these but in theory should work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 16:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-proc-sql-pass-through-xml/m-p/218102#M53626</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2015-05-21T16:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: sas proc sql pass through xml</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-proc-sql-pass-through-xml/m-p/218103#M53627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for reply. I am sure your method would work out, but I feel there should be a more xml-like way to do the job.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 18:36:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-proc-sql-pass-through-xml/m-p/218103#M53627</guid>
      <dc:creator>abcd123</dc:creator>
      <dc:date>2015-05-21T18:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: sas proc sql pass through xml</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-proc-sql-pass-through-xml/m-p/218104#M53628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The more XML like way would need to happen as part of your XMLQuery expression. Once you get the result back it's just a string in a variable and you will need some string operation to get what you want. For the example string you've posted a simple RegEx should do though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table test as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select MyData, prxchange('s/&amp;lt;[^&amp;gt;]+&amp;gt;//oi',-1,MyData) as MyData_TagRemoved&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* and here your pass-through SQL block */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select '&amp;lt;?xml version="1.0" encoding="windows-1252" ?&amp;gt;1234567' as MyData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sashelp.class(obs=1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regular Expressions are also implemented in DB2 &lt;A href="https://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.xml.doc/doc/xqrfnrpl.html" title="https://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.xml.doc/doc/xqrfnrpl.html"&gt;IBM Knowledge Center&lt;/A&gt;. If you can't set-up your XMLQuery in a way that you only get back what you need then I'd probably would try and implement the string parsing/replacement within DB2 - so what I've done in above example with prxchange() - to not transfer unnecessary data from the Database to SAS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 19:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-proc-sql-pass-through-xml/m-p/218104#M53628</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-05-21T19:46:13Z</dc:date>
    </item>
  </channel>
</rss>

