SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Defense
Obsidian | Level 7


My_table has two fields, one is defined as [c_array] char(20), with values like ‘123456781ABCD234’. Another field is defined as [b_array] binary(8). The task is to convert value of c_array into binary and assign it to b_array.

 

thanks

 

3 REPLIES 3
PGStats
Opal | Level 21

Beware of truncation. 20 hexadecimal numbers will require at least 80 bits of binary storage.

PG
Haikuo
Onyx | Level 15

 Are you doing a hex to binary conversion like @PGStats suggested, or a char to binary conversion? If hex-binary, given the length is 20, you may need to read it in as hex one digit at a time, and spit it out as binary, then concatenate them together to the length of 80.  If char-binary, there is a format $binaryw. you may need to use.

 

Take a look at format/informat $binaryw and binaryw.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 3 replies
  • 6496 views
  • 0 likes
  • 4 in conversation