<?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 hexadecimal to character? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259133#M50073</link>
    <description>&lt;P&gt;Hello Rod,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example (tested on a Windows machine):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
v1_hex='030B'x;
v2_hex='4041'x;
run;

data want;
set have;
v1v2_char=put(v1_hex||v2_hex, $hex8.);
run; /* Result: 030B4041 */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If V1_HEX and V2_HEX are character variables of length &amp;gt;2 (i.e. contain trailing blanks), you'll want to replace the assignment statement with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;v1v2_char=put(cats(v1_hex, v2_hex), $hex8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;unless you see a risk that removing leading and trailing blanks (by the CATS function) could truncate any of the two variables (because they happen to contain a blank as the first or second character). In the latter case, you can use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;v1v2_char=put(put(v1_hex,$2.)||put(v2_hex,$2.), $hex8.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 25 Mar 2016 19:44:49 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-03-25T19:44:49Z</dc:date>
    <item>
      <title>How to convert hexadecimal to character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259118#M50066</link>
      <description>&lt;P&gt;I have two variables that are internally stored as two bytes of hex data each. I need to create another variable from these two, such that the new variable is a character concatenation of the two, with the equivalent hexadecimal characters, in this case 8 characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;V1V2_CHAR = CAT(V1_HEX, V2_HEX);&lt;/P&gt;&lt;P&gt;FORMAT V1V2_CHAR $CHAR4. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the variable still prints in hex (non-printable on the screen) but a hex display shows it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I admittedly only use SAS on rare occasions, so pardon my newbi-ness..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Rod&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS. This is SAS on z/OS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2016 18:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259118#M50066</guid>
      <dc:creator>RodFeak</dc:creator>
      <dc:date>2016-03-25T18:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert hexadecimal to character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259133#M50073</link>
      <description>&lt;P&gt;Hello Rod,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example (tested on a Windows machine):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
v1_hex='030B'x;
v2_hex='4041'x;
run;

data want;
set have;
v1v2_char=put(v1_hex||v2_hex, $hex8.);
run; /* Result: 030B4041 */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If V1_HEX and V2_HEX are character variables of length &amp;gt;2 (i.e. contain trailing blanks), you'll want to replace the assignment statement with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;v1v2_char=put(cats(v1_hex, v2_hex), $hex8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;unless you see a risk that removing leading and trailing blanks (by the CATS function) could truncate any of the two variables (because they happen to contain a blank as the first or second character). In the latter case, you can use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;v1v2_char=put(put(v1_hex,$2.)||put(v2_hex,$2.), $hex8.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Mar 2016 19:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259133#M50073</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-25T19:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert hexadecimal to character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259149#M50081</link>
      <description>&lt;P&gt;Given your newness to SAS, I would suggest checking your assumptions about what these variables actually contain. &amp;nbsp;It's simple enough to do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;put v1_hex @4&amp;nbsp;&amp;nbsp;$hex4. &amp;nbsp;@10 v2_hex @13 v2_hex $hex4.;&lt;/P&gt;
&lt;P&gt;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution changes depending on what text is actually in the original variables.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2016 20:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259149#M50081</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-25T20:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert hexadecimal to character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259203#M50104</link>
      <description>Can you try other format Like:  put v1v2_char= $EBCDIC8.;</description>
      <pubDate>Sat, 26 Mar 2016 04:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259203#M50104</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-26T04:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert hexadecimal to character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259329#M50162</link>
      <description>&lt;P&gt;Thanks to all who responded! The PUT was what I was missing and the recommendations solved the problem.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2016 11:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-hexadecimal-to-character/m-p/259329#M50162</guid>
      <dc:creator>RodFeak</dc:creator>
      <dc:date>2016-03-28T11:54:17Z</dc:date>
    </item>
  </channel>
</rss>

