<?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: Packed hexa decimal  to  ascii conversion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Packed-hexa-decimal-to-ascii-conversion/m-p/794384#M254719</link>
    <description>&lt;P&gt;Judging by your program, you appear to be signing on to a mainframe SAS session, then running a DB2 query there. What is the data type of the column being queried in DB2? Also run a PROC CONTENTS on the SAS dataset created by the query on the mainframe before it is downloaded and post the results. Does the data look the same in the mainframe SAS session as it does once you have downloaded it?&lt;/P&gt;</description>
    <pubDate>Fri, 04 Feb 2022 02:31:51 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2022-02-04T02:31:51Z</dc:date>
    <item>
      <title>Packed hexa decimal  to  ascii conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Packed-hexa-decimal-to-ascii-conversion/m-p/794379#M254718</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to convert packed Hexa Decimal&amp;nbsp; value to a character value in sas .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Background is ,Using the below query I am downloading&amp;nbsp; from IBM x86.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rsubmit;&lt;BR /&gt;%macro DownloadTables (inSchema,intable,out);&lt;BR /&gt;* Download tables *;&lt;BR /&gt;%include 'macros/connect.sas';&lt;BR /&gt;options validvarname=any;&lt;BR /&gt;proc sql;&lt;BR /&gt;connect to db2 as pscon(&lt;BR /&gt;user=&amp;amp;user&lt;BR /&gt;password=&amp;amp;password&lt;BR /&gt;database=&amp;amp;database&lt;BR /&gt;);&lt;BR /&gt;create table &amp;amp;out. as&lt;BR /&gt;select * from connection to pscon (&lt;BR /&gt;select&lt;/P&gt;
&lt;P&gt;MH_Data&lt;BR /&gt;from &amp;amp;inSchema..&amp;amp;intable.&lt;BR /&gt;where date(TIMESTAMP) &amp;gt;= current date - 30 days&lt;/P&gt;
&lt;P&gt;WITH UR&lt;BR /&gt;) ;&lt;BR /&gt;disconnect from pscon;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;%mend;&lt;BR /&gt;%DownloadTables (inschema,intable,outtable);&lt;BR /&gt;endrsubmit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for some reason , in sas it is hex format as below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="swathiprasad_1-1643937101018.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68188i06578326A72D6BD7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="swathiprasad_1-1643937101018.png" alt="swathiprasad_1-1643937101018.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example of data:F0F0F0F0C1F1F0F5F0F0F0F0F0F9F240D5404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040D72020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to convert this hex to ascii/char .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Request help on this!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 01:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Packed-hexa-decimal-to-ascii-conversion/m-p/794379#M254718</guid>
      <dc:creator>sfffdg</dc:creator>
      <dc:date>2022-02-04T01:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Packed hexa decimal  to  ascii conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Packed-hexa-decimal-to-ascii-conversion/m-p/794384#M254719</link>
      <description>&lt;P&gt;Judging by your program, you appear to be signing on to a mainframe SAS session, then running a DB2 query there. What is the data type of the column being queried in DB2? Also run a PROC CONTENTS on the SAS dataset created by the query on the mainframe before it is downloaded and post the results. Does the data look the same in the mainframe SAS session as it does once you have downloaded it?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 02:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Packed-hexa-decimal-to-ascii-conversion/m-p/794384#M254719</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-02-04T02:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Packed hexa decimal  to  ascii conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Packed-hexa-decimal-to-ascii-conversion/m-p/794390#M254722</link>
      <description>Yeah ,I am signing in to a unix box through remote session , then running a DB2 query there.&lt;BR /&gt;&lt;BR /&gt;I have checked the DB2 ,its data type  is varchar(2000) for bit data.Yes  the data looks the same in db2 as well.</description>
      <pubDate>Fri, 04 Feb 2022 04:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Packed-hexa-decimal-to-ascii-conversion/m-p/794390#M254722</guid>
      <dc:creator>sfffdg</dc:creator>
      <dc:date>2022-02-04T04:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Packed hexa decimal  to  ascii conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Packed-hexa-decimal-to-ascii-conversion/m-p/794392#M254724</link>
      <description>&lt;P&gt;I don't see any packed decimal there.&lt;/P&gt;
&lt;P&gt;It just looks like EBCIDIC.&amp;nbsp; All of those 40 codes are spaces in EBCIDIC.&amp;nbsp; Then the end of the string looks like 20 codes where are spaces in ASCII.&amp;nbsp; It is like you copied the EBCIDIC string into a longer SAS variable, so it was padded with spaces (just as SAS does with all character variables.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your posted example looks like this:&lt;/P&gt;
&lt;PRE&gt;14    data check;
15      string='F0F0F0F0C1F1F0F5F0F0F0F0F0F9F240D540'x;
16      format string $hex.;
17      length = length(string);
18      ASCII = input(string,$ebcdic18.);
19      put (string length ascii) (=/);
20    run;


string=F0F0F0F0C1F1F0F5F0F0F0F0F0F9F240D540
length=18
ASCII=0000A1050000092 N
&lt;/PRE&gt;
&lt;P&gt;Is that what you expected?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 04:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Packed-hexa-decimal-to-ascii-conversion/m-p/794392#M254724</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-04T04:29:34Z</dc:date>
    </item>
  </channel>
</rss>

