BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MarkATremel
Obsidian | Level 7

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!

1 ACCEPTED SOLUTION
4 REPLIES 4
MarkATremel
Obsidian | Level 7

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
ballardw
Super User

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

 

MarkATremel
Obsidian | Level 7

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=

 

 

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1440 views
  • 1 like
  • 3 in conversation