<?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 How can one correctly input big and little endian hex representations? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27158#M4921</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes it is a common issue, you can read about it more it is commonly referred to as the NUXI problem, I beleive.&amp;nbsp; It is because of the particularities of the system running to code and what that systems endianess is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Oct 2011 17:09:23 GMT</pubDate>
    <dc:creator>FriedEgg</dc:creator>
    <dc:date>2011-10-11T17:09:23Z</dc:date>
    <item>
      <title>How can one correctly input big and little endian hex representations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27152#M4915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following is what I've tried thus far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; filename='c:\art\file1.dat';&lt;/P&gt;&lt;P&gt;&amp;nbsp; file dummy filevar=filename recfm=f lrecl=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 24 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input char $hex2. +1 @;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put char $char1. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;FF D8 FF E0 17 00 4A 46 49 46 00 01 01 01 00 60 00 60 00 00 FF E1 5C 1C&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'c:\art\file1.dat';&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x=input(substr(_infile_,5,2),pibr4.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; y=input(substr(_infile_,5,2),pib4.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would have expected x to have a value of 23 and y to have a value of 5888, but they both get a value of 23.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Oct 2011 22:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27152#M4915</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-10T22:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can one correctly input big and little endian hex representations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27153#M4916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art - &lt;/P&gt;&lt;P&gt;I do not think that the PIBR informat does what you want. From reading the man page I cannot figure out what it is supposed to do.&lt;/P&gt;&lt;P&gt;You should use the REVERSE function to change the byte order.&amp;nbsp; Also make your informat length match your data length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input x $hex4. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; front = input(x,pib2.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; back = input(reverse(x),pib2.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put x= hex4. front= back= ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;0100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;1700 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x=0100 front=1 back=256&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x=1700 front=23 back=5888&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 00:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27153#M4916</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-11T00:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can one correctly input big and little endian hex representations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27154#M4917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reverse is definitely a possibility and I am currently rewriting the code accordingly to see if it will correct the problem.&amp;nbsp; It is a bit late, already, thus I probably won't get to test it until tomorrow morning.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 02:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27154#M4917</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-11T02:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can one correctly input big and little endian hex representations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27155#M4918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ran the above code on Intel PC, Win XP, SAS 9.1.3, and both x and y are 23.&lt;/P&gt;&lt;P&gt;I think on Intel machines, SAS informat of pib4. (native format) and pibr4. (intel format) are the same so x and y have the same value.&lt;/P&gt;&lt;P&gt;If i use s370fpib2. this switches to a different endian from the Intel PC, and generates 5888.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 15:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27155#M4918</guid>
      <dc:creator>DLing</dc:creator>
      <dc:date>2011-10-11T15:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can one correctly input big and little endian hex representations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27156#M4919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very good work so far.&amp;nbsp; Here is a great reference point for your topic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001258728.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001258728.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 16:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27156#M4919</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-10-11T16:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can one correctly input big and little endian hex representations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27157#M4920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, but I had already read that, yet didn't discover (realize) the answer until DLing had recommended trying the s370fpib2 informat.&amp;nbsp; Once I correct all of the code and get it running on an XP, I'll have to see if it works the same on all other systems.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 16:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27157#M4920</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-11T16:49:08Z</dc:date>
    </item>
    <item>
      <title>How can one correctly input big and little endian hex representations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27158#M4921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes it is a common issue, you can read about it more it is commonly referred to as the NUXI problem, I beleive.&amp;nbsp; It is because of the particularities of the system running to code and what that systems endianess is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 17:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27158#M4921</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-10-11T17:09:23Z</dc:date>
    </item>
    <item>
      <title>How can one correctly input big and little endian hex representations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27159#M4922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dealing with endian-ness is no fun, actually it's a royal pain in the rear.&amp;nbsp; We have IBM mainframes, Solaris UNIX mid-range servers and Intel PC's.&amp;nbsp; You need to know the endian of the data as well as the endian of the machine you are running on to pick the right formats/informats.&amp;nbsp; Most people (rightly so) don't want to care about how machines store numbers.&amp;nbsp; Those that grew up accessing databases never had to worry about data representation and are shocked that this is even necessary.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 17:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27159#M4922</guid>
      <dc:creator>DLing</dc:creator>
      <dc:date>2011-10-11T17:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can one correctly input big and little endian hex representations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27160#M4923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the s370fpipW informat, where applicable, solved all of my problems.&amp;nbsp; The data structure I am working on specifies whether numbers are represented in big or little endian form.&amp;nbsp; Interestingly, wnen trying to use the Window's Explorer in XP to change a pictures title, it changed the from from little to big endian (along with totally messing up the industry standards for the format).&amp;nbsp; I'll post my current code, shortly, in the thread that is actually dealing with the whole solution (see: &lt;A _jive_internal="true" href="https://communities.sas.com/message/107245#107245"&gt;http://communities.sas.com/message/107245#107245&lt;/A&gt; ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom's suggestion for using the reverse function was definitely also a possibility, but required the code to be a lot messier.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 20:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-one-correctly-input-big-and-little-endian-hex/m-p/27160#M4923</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-11T20:39:22Z</dc:date>
    </item>
  </channel>
</rss>

