<?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: How to convert column from hexadecimal to character? Error &amp;quot;components are of different dat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-column-from-hexadecimal-to-character-Error-quot/m-p/739949#M231039</link>
    <description>&lt;P&gt;You left out the most important part of the CONTENTS informat.&amp;nbsp; What the TYPE of the variable is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But we can tell from the FORMAT that is attached that it is a NUMERIC variable and NOT a character varaible.&lt;/P&gt;
&lt;P&gt;So it could never have a value like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;'myqueryID'&lt;/PRE&gt;
&lt;P&gt;which is a string of letters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to type a hex constant start with the digits 0 and end it with the letter X.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE ID_td = 0ABCDEF12x ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which is the same thing as writing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where id_td = 2882400018 ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;because the base 16 number&amp;nbsp;0ABCDEF12 is the same as the decimal number&amp;nbsp;2,882,400,018.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 08 May 2021 04:13:41 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-05-08T04:13:41Z</dc:date>
    <item>
      <title>How to convert column from hexadecimal to character? Error "components are of different data type"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-column-from-hexadecimal-to-character-Error-quot/m-p/739924#M231024</link>
      <description>&lt;P&gt;I have a table with an ID column (ID_td). When I try to query, I get the error "expression using equals has components that are of different data types".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;SELECT ID_td&lt;BR /&gt;FROM mytable&lt;BR /&gt;WHERE ID_td = 'myqueryID'&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked with proc contents, I see that the column is hexadecimal :&lt;/P&gt;&lt;P&gt;Length: 6&lt;/P&gt;&lt;P&gt;Format: HEX8.&lt;/P&gt;&lt;P&gt;Informat: 9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I need to convert from hexadecimal to character? How would I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 23:44:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-column-from-hexadecimal-to-character-Error-quot/m-p/739924#M231024</guid>
      <dc:creator>DougHold</dc:creator>
      <dc:date>2021-05-07T23:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert column from hexadecimal to character? Error "components are of different dat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-column-from-hexadecimal-to-character-Error-quot/m-p/739940#M231034</link>
      <description>&lt;P&gt;Proc Contents also tells you of what data type a variable is. With SAS it's either numeric or character.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1620440895307.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59155i947025F1FE3CE5F7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1620440895307.png" alt="Patrick_0-1620440895307.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your query you've got:&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;WHERE ID_td = 'myqueryID'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And SAS tells you:&amp;nbsp;"expression using equals has components that &lt;FONT color="#FF0000"&gt;are of different data types&lt;/FONT&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; 'myqueryID' is a character string but variable ID_td is of type numeric and that's what the error message tells you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;A format only instructs SAS how to print a values. It has no impact on the actually stored value and doesn't come into play in an expression like your where condition which always will use the internal value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want to print your variable using another format just do something like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc print data=mytable(obs=3);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;format ID_td 32.;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;variable ID_td;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 May 2021 02:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-column-from-hexadecimal-to-character-Error-quot/m-p/739940#M231034</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-05-08T02:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert column from hexadecimal to character? Error "components are of different dat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-column-from-hexadecimal-to-character-Error-quot/m-p/739949#M231039</link>
      <description>&lt;P&gt;You left out the most important part of the CONTENTS informat.&amp;nbsp; What the TYPE of the variable is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But we can tell from the FORMAT that is attached that it is a NUMERIC variable and NOT a character varaible.&lt;/P&gt;
&lt;P&gt;So it could never have a value like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;'myqueryID'&lt;/PRE&gt;
&lt;P&gt;which is a string of letters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to type a hex constant start with the digits 0 and end it with the letter X.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE ID_td = 0ABCDEF12x ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which is the same thing as writing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where id_td = 2882400018 ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;because the base 16 number&amp;nbsp;0ABCDEF12 is the same as the decimal number&amp;nbsp;2,882,400,018.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 May 2021 04:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-column-from-hexadecimal-to-character-Error-quot/m-p/739949#M231039</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-08T04:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert column from hexadecimal to character? Error "components are of different dat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-column-from-hexadecimal-to-character-Error-quot/m-p/740629#M231405</link>
      <description>&lt;P&gt;Thank you Patrick and Tom for the reply, that will be important to keep in mind.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did check again, and the variable ID_td is indeed type character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to resolve my issue by inserting a new ID character column (ID_td2):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data mytable;&lt;/P&gt;&lt;P&gt;Set mytable;&lt;/P&gt;&lt;P&gt;ID_td2 = put(ID_td, $hex8.);&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 22:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-column-from-hexadecimal-to-character-Error-quot/m-p/740629#M231405</guid>
      <dc:creator>DougHold</dc:creator>
      <dc:date>2021-05-11T22:24:45Z</dc:date>
    </item>
  </channel>
</rss>

