I need to input two hexadecimal bytes and manipulate the 4 nibbles that are contained within. For example, the two bytes in the file contain '13BC'x. The first nibble is '1', the second nibble is '3', the third nibble is 'B' and the fourth nibble is 'C'. Due to some *creative* programming, I need to isolate the first nibble and interpret it and then isolate the last three nibbles and interpret them. If the 4 nibbles can be converted to a string, I can proceed from there.
Does anyone know which informat and/or functions I would use to produce a 4 char string of hex characters that I can then manipulate?
Note: I am a long time mainframe base SAS user, but first time question asker! Thanks in advance for any hints, suggestions or outright answers!
Thank you for your response. However, before I try this, I notice that the SAS documentation says that for this informat, this is the behavior, but I would need it to write 6C6C to the SAS log.
Example
data test;
name='6C6C';
name2=input(name,$hex4.);
run;
SAS writes the following output to the log:
11
When you use an INPUT then you are using an INFORMAT to read text into numeric values. You said that you already have a hex value.
See the difference with this which uses an existing Hex value and creates the desired character value:
data test; name='6C6C'x; name2=put(name,$hex4.); run;
PUT uses the FORMAT to display the value.
@MarkATremel wrote:
Thank you for your response. However, before I try this, I notice that the SAS documentation says that for this informat, this is the behavior, but I would need it to write 6C6C to the SAS log.
Example
data test; name='6C6C'; name2=input(name,$hex4.); run;
SAS writes the following output to the log:
11
More detail: I hope this helps to explain my situation better.
INPUT...
@0553 SUSPCD01 $HEX4.
@0555 SUSPCD02 $HEX4.
@0557 SUSPCD03 $HEX4.
...
NOTE: Invalid data for SUSPCD01 in line 2 553-556.
NOTE: Invalid data for SUSPCD02 in line 2 555-558.
NOTE: Invalid data for SUSPCD03 in line 2 557-560.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+
501 ..................................................... . . ...........
ZONE 00000000000000000000000000000000000000000000000000001B1B1B00000000000
NUMR 00000000000000000000000000000000000000000000000000003CBCBC00000000000
SUSPCD01= SUSPCD02= SUSPCD03=
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.