Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading in Hex data

Status
Not open for further replies.

cojiro

MIS
Mar 20, 2003
62
US
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
;
 
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 %%


 
Thanks, but I can't get it to work. My output keeps coming out in hex no matter what I do.
 
Can you provide a few lines of data and the data lay out?

It hard to tell without knowing what you have.



 
thanks, but my assignment has changed. I no longer need to do this. I appreciate the help though.
 
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.
 
Thanks, even though I'm not doing this anymore, its good to know what I'm trying to code actually means.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top