BookmarkSubscribeRSS Feed
esirjhm
Calcite | Level 5

The following code seems to have two different results with a 10.5 format when the two values in hexidecimal are identical.  What am I missing?

DATA TEST;                                                 

  HMWID = 62.7;                                             

  LIN_FT = 1;                                               

  RUN;                                                      

DATA AVAL (KEEP = K FT);                                   

  ARRAY LAR{240:799} _TEMPORARY_;                           

  SET TEST END=END;                                         

  PUTLOG HMWID=10.5  +3 HMWID=HEX16.;                       

  HMWID = HMWID * 10;                                       

  PUTLOG 'STORING VALUE '  HMWID=10.5 +3   HMWID=HEX16.;    

  LAR{HMWID} + LIN_FT;                                      

  IF END;                                                   

  DO J = 240 TO (799-40);                                   

     K  = J;                                                

     FT = LAR{J};                                           

     IF FT THEN DO;                                         

        OUTPUT AVAL;                                        

        PUTLOG 'RESTORING VALUE ' K=10.5 +3 HMWID=HEX16.;   

     END;                                                   

  END;                                                      

  RUN; 

Output results...                                                    

HMWID=62.70000    HMWID=423EB33333333333               

STORING VALUE HMWID=627.00000    HMWID=43272FFFFFFFFFFF

RESTORING VALUE K=626.00000    HMWID=43272FFFFFFFFFFF  

1 REPLY 1
DLing
Obsidian | Level 7

Doesn't look like anything is wrong. Don't unerstand why you're showing for RESTORING K not being 627.

What's posted looks like an excerpt from a much larger program, perhaps the culprit is elsewhere and got edited out.

By the way, display format, like 10.5, have nothing to do with internal precision.

1 DATA TEST;

2 HMWID = 62.7;

3 LIN_FT = 1;

4 RUN;

NOTE: The data set WORK.TEST has 1 observations and 2 variables.

NOTE: DATA statement used (Total process time):

real time 0.01 seconds

cpu time 0.01 seconds

 

5

6 DATA AVAL (KEEP = K FT);

7 ARRAY LAR{240:799} _TEMPORARY_;

8 SET TEST END=END;

9 PUTLOG HMWID=10.5 +3 HMWID=HEX16.;

10

11 HMWID = HMWID * 10;

12 PUTLOG 'STORING VALUE ' HMWID=10.5 +3 HMWID=HEX16.;

13 LAR{HMWID} + LIN_FT;

14

15 IF END;

16

17 DO J = 240 TO (799-40);

18 K = J;

19 FT = LAR{J};

20 IF FT THEN DO;

21 OUTPUT AVAL;

22 PUTLOG 'RESTORING VALUE ' K=10.5 +3 HMWID=HEX16.;

23 END;

24 END;

25 RUN;

HMWID=62.70000 HMWID=404F59999999999A

STORING VALUE HMWID=627.00000 HMWID=4083980000000000

RESTORING VALUE K=627.00000 HMWID=4083980000000000

NOTE: There were 1 observations read from the data set WORK.TEST.

NOTE: The data set WORK.AVAL has 1 observations and 2 variables.

NOTE: DATA statement used (Total process time):

real time 0.03 seconds

cpu time 0.01 seconds

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 633 views
  • 0 likes
  • 2 in conversation