×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Reading in Hex data

Reading in Hex data

Reading in Hex data

(OP)
This is really my first SAS report I've written.  I can't figure out how to read in the data that is stored in hex.  Any suggestions you could give me would be appreciated.  I've tried things like the following, but I don't even know if I'm close.
INPUT                    
@040  COMPANY       $2.  
@130  GROSSFSYRCOM  ZD3.2
@231  ENDINGADVAN   ZD7.2
@294  ENDINGRESRVE  ZD7.2
@308  NETCOMDUE     ZD7.2
@315  NETRENEWCOM   ZD7.2
;                        

RE: Reading in Hex data

I have never had the need fro reading hex data, but here is what sas says:

$HEXw.


--------------------------------------------------------------------------------

Converts hexadecimal data to character data
Category: Character  



--------------------------------------------------------------------------------
Syntax
Syntax Description
Details
Comparisons
Examples

--------------------------------------------------------------------------------
 
Syntax
$HEXw.  


Syntax Description

w
specifies the number of digits of hexadecimal data.
If w=1, $HEXw. pads a trailing hexadecimal 0. If w is an odd number that is greater than 1, then $HEXw. reads w-1 hexadecimal characters. Default: 2
Range: 1-32767




--------------------------------------------------------------------------------
 
Details


The $HEXw. informat converts every two digits of hexadecimal data into one byte of character data. Use $HEXw. to encode hexadecimal values into a character variable when your input method is limited to printable characters.


--------------------------------------------------------------------------------
 
Comparisons


The HEXw. informat reads two digits of hexadecimal data at a time and converts them into one byte of numeric data.


--------------------------------------------------------------------------------
 
Examples



input @1 name $hex4.;

Data Lines Results
----+----1
Hex   ASCII EBCDIC
6C6C   11    %%
 

RE: Reading in Hex data

(OP)
Thanks, but I can't get it to work.  My output keeps coming out in hex no matter what I do.

RE: Reading in Hex data

Can you provide a few lines of data and the data lay out?

It hard to tell without knowing what you have.



RE: Reading in Hex data

(OP)
thanks, but my assignment has changed.  I no longer need to do this.  I appreciate the help though.

RE: Reading in Hex data

fyi cojiro - you were close

ZD is 'Zoned Decimal'  --- it is actually a character number (so if you browse the file you would actually see 1234.56)

PD is 'Packed decimal' --- the first number is the number of CHARS that is the length (so pd7.2 would be hex '00000000000000c' - or the equivilent of a fixed dec 13.2)

if it were a binary number you would use IB2.0

Like teralearner, I have never had to use HEX... but I think this is really what you were trying to do.

So I am betting that your ZDs should just have been PD - good luck when this project comes back to you again.

RE: Reading in Hex data

(OP)
Thanks, even though I'm not doing this anymore, its good to know what I'm trying to code actually means.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close