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
;
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
$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
RE: Reading in Hex data
It hard to tell without knowing what you have.
RE: Reading in Hex data
RE: Reading in Hex data
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