BookmarkSubscribeRSS Feed
capam
Pyrite | Level 9

I'm using the following command line:

 

SUBID_IN_HEX = input(SUBID_IN_HEX,hex.);

 

If I input as follows:

 

SUBID_IN_HEX = input('33b',hex.); SUBID_IN_HEX = 827 which is correct. However if I input 

SUBID_IN_HEX = input('40b',hex.); SUBID_IN_HEX = 1E3 which should be 1035.

 

How do I correct the code to ensure no rounding/approximations occur? The digits may go to > 10. 

 

Thanks for your time.

Steve

4 REPLIES 4
Astounding
PROC Star

Steve,

 

So far, there is not conclusive evidence that any rounding has taken place.  You may just need to user a wider format for printing the value of SUBID_IN_HEX.  Try printing with:

 

format SUBID_IN_HEX 4.;

 

capam
Pyrite | Level 9
Thanks. Subsequent usage says that it is using 1000 instead of 1035, for example.
ChrisNZ
Tourmaline | Level 20

I agree with @ballardw. Formatting is likely to be the issue, not the value. Or you havent told us everything.


data _null_;
  SUBID_IN_HEX = input('40b',hex.); 
  putlog SUBID_IN_HEX =;
run;

SUBID_IN_HEX=1035

 

 

ballardw
Super User

You apparently have assigned a 3 column format to the variable somewhere. Please see:

data junk;
   v = input('40b',hex.); 
   put 'Fixed 3 column format: ' + 1v= f3. +1 'Best format allowing 6 columns: ' +1v= best6.;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 394 views
  • 0 likes
  • 4 in conversation