<?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 XML Engine - A function / method equivalent of value() Method (xml Data Type) of Transact SQ in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-XML-Engine-A-function-method-equivalent-of-value-Method-xml/m-p/328217#M73277</link>
    <description>Hi:&lt;BR /&gt;  Sort of sounds like it works like an XMLMap, when you use an XMLMap, you write instructions for how SAS can read an XML file into SAS format and populate the columns on each row with information from the XML tags. This paper has some good explanations and examples of importing an XML file into SAS using an XMLMap:&lt;BR /&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings12/253-2012.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings12/253-2012.pdf&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;cynthia</description>
    <pubDate>Sat, 28 Jan 2017 14:51:18 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2017-01-28T14:51:18Z</dc:date>
    <item>
      <title>SAS XML Engine - A function / method equivalent of value() Method (xml Data Type) of Transact SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-XML-Engine-A-function-method-equivalent-of-value-Method-xml/m-p/328057#M73223</link>
      <description>&lt;P&gt;&lt;FONT color="#993300" face="trebuchet ms,geneva"&gt;Is there any built-in function/method in SAS-XML engine&amp;nbsp;which is equivalent of &lt;STRONG&gt;"value() Method (xml Data Type)" &lt;/STRONG&gt;of &lt;STRONG&gt;Transact SQL &lt;/STRONG&gt;(Microsoft) ?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="trebuchet ms,geneva"&gt;Details on &lt;FONT face="Trebuchet MS"&gt;&lt;STRONG&gt;"value() Method (xml Data Type)" &lt;/STRONG&gt;of &lt;STRONG&gt;Transact SQL &lt;/STRONG&gt;&lt;/FONT&gt;can be found in below link&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="trebuchet ms,geneva"&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/ms178030.aspx" target="_blank"&gt;https://msdn.microsoft.com/en-us/library/ms178030.aspx&lt;/A&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="trebuchet ms,geneva"&gt;Above method performs an XQuery against the XML and returns a value of SQL type. This method returns a scalar value.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="trebuchet ms,geneva"&gt;One can use this method to extract a value from an XML instance stored in an &lt;STRONG&gt;xml&lt;/STRONG&gt; type column, parameter, or variable. In this way, you can specify SELECT queries that combine or compare XML data with data in non-XML columns.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3 class="subHeading"&gt;&lt;FONT face="trebuchet ms,geneva"&gt;&lt;A id="A-Using-the-value-method-against-an-xml-type-variable" target="_blank"&gt;&lt;/A&gt;A. Using the value() method against an xml type variable&lt;/FONT&gt;&lt;/H3&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="trebuchet ms,geneva"&gt;In the following example, an XML instance is stored in a variable of &lt;CODE&gt;xml&lt;/CODE&gt; type. The &lt;CODE&gt;value()&lt;/CODE&gt; method retrieves the &lt;CODE&gt;ProductID&lt;/CODE&gt; attribute value from the XML. The value is then assigned to an &lt;CODE&gt;int&lt;/CODE&gt; variable.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="trebuchet ms,geneva"&gt;DECLARE @myDoc xml  
DECLARE @ProdID int  
SET @myDoc = '&amp;lt;Root&amp;gt;  
&amp;lt;ProductDescription ProductID="1" ProductName="Road Bike"&amp;gt;  
&amp;lt;Features&amp;gt;  
  &amp;lt;Warranty&amp;gt;1 year parts and labor&amp;lt;/Warranty&amp;gt;  
  &amp;lt;Maintenance&amp;gt;3 year parts and labor extended maintenance is available&amp;lt;/Maintenance&amp;gt;  
&amp;lt;/Features&amp;gt;  
&amp;lt;/ProductDescription&amp;gt;  
&amp;lt;/Root&amp;gt;'  
  
SET @ProdID =  @myDoc.value('(/Root/ProductDescription/@ProductID)[1]', 'int' )  
SELECT @ProdID  

&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="trebuchet ms,geneva"&gt;Value 1 is returned as a result.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="trebuchet ms,geneva"&gt;Although there is only one &lt;CODE&gt;ProductID&lt;/CODE&gt; attribute in the XML instance, the static typing rules require you to explicitly specify that the path expression returns a singleton. Therefore, the additional &lt;CODE&gt;[1]&lt;/CODE&gt; is specified at the end of the path expression. For more information about static typing, see &lt;A href="https://msdn.microsoft.com/en-us/library/ms190938.aspx" target="_blank"&gt;XQuery and Static Typing&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 16:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-XML-Engine-A-function-method-equivalent-of-value-Method-xml/m-p/328057#M73223</guid>
      <dc:creator>nrk1787db1</dc:creator>
      <dc:date>2017-01-27T16:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS XML Engine - A function / method equivalent of value() Method (xml Data Type) of Transact SQ</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-XML-Engine-A-function-method-equivalent-of-value-Method-xml/m-p/328217#M73277</link>
      <description>Hi:&lt;BR /&gt;  Sort of sounds like it works like an XMLMap, when you use an XMLMap, you write instructions for how SAS can read an XML file into SAS format and populate the columns on each row with information from the XML tags. This paper has some good explanations and examples of importing an XML file into SAS using an XMLMap:&lt;BR /&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings12/253-2012.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings12/253-2012.pdf&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Sat, 28 Jan 2017 14:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-XML-Engine-A-function-method-equivalent-of-value-Method-xml/m-p/328217#M73277</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-01-28T14:51:18Z</dc:date>
    </item>
  </channel>
</rss>

