BookmarkSubscribeRSS Feed
hhchenfx
Rhodochrosite | Level 12

Hi Everyone,

I use proc expand to get Max value of price. I know for sure that, the max value of price is 147212 and proc expand return the same value. 

proc expand data=M1 out=M1;
by tic;
convert price=price_top_&window/transformout=(MOVmax &window );
run;

However, when I check the condition below, SAS doesn't return top=1 for the record with highest price.

 

if price = price_top_&window then top=1;

After some checking, it turns out that, some how the price_top_&window is fractional greater than 147212. 

When I take Price - price_top_&window, SAS return value -2.91038E-11, which is -0.0000000000291038

All of my data are integer.

I wonder how that happens and how to fix it.

Thank you,

 

 

 

 

 

1 REPLY 1
Reeza
Super User
Numeric Precision issue.

if round(price,1) = round(price_top_&window, 1) then top=1;

Lookup the round function to find the nearest level of precision that you would like to match on.

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