<?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 SAS error from SQL query of XML data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-from-SQL-query-of-XML-data/m-p/476899#M122753</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use a SQL query in SAS to pull some data that is in a SAS library. However, there is an field with XML data that keeps giving me an error if I try to extract the data for a particular month. I assume it's a character that isn't recognized, but I can't actually see the data. All of the other months that I have tried to extract work fine, and my query works if I remove the XML field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I might be able to adjust the code to fix this? I am using SAS 9.4 Classic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error that I get is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: CLI cursor extended fetch error: [IBM][CLI Driver][DB2/AIX64] SQL20412N Serialization of an XML value resulted&lt;/P&gt;&lt;P&gt;in characters that could not be represented in the target encoding. SQLSTATE=2200W&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query that I've been running is (Error is in the field USER_EVENT_REMARKS):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; psi_privacy &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Event.USER_EVENT_SYS_ID, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_USER_ID,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_TMSTMP,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_CODE,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_FUNC_CNTXT_CODE,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_ACCESS_TYPE_CODE,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_CURRENT_ROLES,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_IP_ADDRESS,&lt;/P&gt;&lt;P&gt;Event.ORG_FAC_ID,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_REMARKS,&lt;/P&gt;&lt;P&gt;J.lab_test_review_result_sys_id,&lt;/P&gt;&lt;P&gt;R.PREFERRED_IDENTIFIER,&lt;/P&gt;&lt;P&gt;R.PREFERRED_NAME_LAST,&lt;/P&gt;&lt;P&gt;R.PREFERRED_NAME_FIRST,&lt;/P&gt;&lt;P&gt;C.BIRTH_DATE&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;psiprod.User_Event Event&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;LEFT&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;JOIN&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; psiprod.lab_test_review_result &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; J &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;ON&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Event.accessed_entity_sys_id=J.lab_test_review_result_sys_id &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FULL&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;JOIN&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; psiprod.lab_report &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; R &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;ON&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; R.lab_report_sys_id = J.lab_report_sys_id&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FULL&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;JOIN&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; psiprod.lab_rpt_client &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; C &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;ON&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; C.lab_report_sys_id = J.lab_report_sys_id&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; month((Event.USER_EVENT_TMSTMP))=&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;month.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jul 2018 18:32:07 GMT</pubDate>
    <dc:creator>CSmo</dc:creator>
    <dc:date>2018-07-10T18:32:07Z</dc:date>
    <item>
      <title>SAS error from SQL query of XML data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-from-SQL-query-of-XML-data/m-p/476899#M122753</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use a SQL query in SAS to pull some data that is in a SAS library. However, there is an field with XML data that keeps giving me an error if I try to extract the data for a particular month. I assume it's a character that isn't recognized, but I can't actually see the data. All of the other months that I have tried to extract work fine, and my query works if I remove the XML field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I might be able to adjust the code to fix this? I am using SAS 9.4 Classic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error that I get is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: CLI cursor extended fetch error: [IBM][CLI Driver][DB2/AIX64] SQL20412N Serialization of an XML value resulted&lt;/P&gt;&lt;P&gt;in characters that could not be represented in the target encoding. SQLSTATE=2200W&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query that I've been running is (Error is in the field USER_EVENT_REMARKS):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; psi_privacy &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Event.USER_EVENT_SYS_ID, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_USER_ID,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_TMSTMP,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_CODE,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_FUNC_CNTXT_CODE,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_ACCESS_TYPE_CODE,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_CURRENT_ROLES,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_IP_ADDRESS,&lt;/P&gt;&lt;P&gt;Event.ORG_FAC_ID,&lt;/P&gt;&lt;P&gt;Event.USER_EVENT_REMARKS,&lt;/P&gt;&lt;P&gt;J.lab_test_review_result_sys_id,&lt;/P&gt;&lt;P&gt;R.PREFERRED_IDENTIFIER,&lt;/P&gt;&lt;P&gt;R.PREFERRED_NAME_LAST,&lt;/P&gt;&lt;P&gt;R.PREFERRED_NAME_FIRST,&lt;/P&gt;&lt;P&gt;C.BIRTH_DATE&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;psiprod.User_Event Event&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;LEFT&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;JOIN&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; psiprod.lab_test_review_result &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; J &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;ON&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Event.accessed_entity_sys_id=J.lab_test_review_result_sys_id &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FULL&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;JOIN&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; psiprod.lab_report &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; R &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;ON&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; R.lab_report_sys_id = J.lab_report_sys_id&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FULL&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;JOIN&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; psiprod.lab_rpt_client &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; C &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;ON&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; C.lab_report_sys_id = J.lab_report_sys_id&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; month((Event.USER_EVENT_TMSTMP))=&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;month.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 18:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-from-SQL-query-of-XML-data/m-p/476899#M122753</guid>
      <dc:creator>CSmo</dc:creator>
      <dc:date>2018-07-10T18:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS error from SQL query of XML data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-from-SQL-query-of-XML-data/m-p/476906#M122757</link>
      <description>&lt;P&gt;It might be because of encoding issue. You might need to use UTF-8 encoding instead of&amp;nbsp;LATIN1. What SAS IDE are you using?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have PC SAS installed then you can might have SAS utf-8 (Start/all programs /sas/sas utf-8), try running there or &lt;A href="http://support.sas.com/kb/51/586.html" target="_self"&gt;check this&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Check your SAS Session encoding:&lt;/P&gt;
&lt;PRE class="codeFragment"&gt;proc options option=encoding;    
run; &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 18:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-from-SQL-query-of-XML-data/m-p/476906#M122757</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-07-10T18:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS error from SQL query of XML data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-from-SQL-query-of-XML-data/m-p/476911#M122760</link>
      <description>&lt;P&gt;Thanks for your response. It is utf-8:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;183 proc options option=encoding;&lt;/P&gt;&lt;P&gt;184 run;&lt;/P&gt;&lt;P&gt;SAS (r) Proprietary Software Release 9.4 TS1M3&lt;/P&gt;&lt;P&gt;ENCODING=UTF-8 Specifies the default character-set encoding for the SAS session.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That file from the link you sent is &lt;SPAN style="font-family: monospace;"&gt;&lt;STRONG&gt;-config "C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg" rather than the U8. Would I need to change it to U8?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively,&amp;nbsp;do you know if there is a way to&amp;nbsp;change the encoding through a SAS code instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 19:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-from-SQL-query-of-XML-data/m-p/476911#M122760</guid>
      <dc:creator>CSmo</dc:creator>
      <dc:date>2018-07-10T19:10:51Z</dc:date>
    </item>
  </channel>
</rss>

