Quantcast
Channel: Statistics Help @ Talk Stats Forum - SAS
Viewing all articles
Browse latest Browse all 310

closest value into a macro variable

$
0
0
Hi everyone,

I have a numeric variable, lets call it 'times'. I have a macro variable 'myTime' defined to be some value, lets say 200. I would like to extract the closest value in 'times' to 'myTime' as a new macro variable 'closestTime'.

Would anyone know how to modify the code below so it gives the closest time instead of the smallest difference? (Or know of some other way I could extract the closest time into a macro variable?). Help is much appreciated!

proc sql noprint;
select min(abs(times-&myTime) )
into :closestTime
from myData;
quit;

thank you!

Viewing all articles
Browse latest Browse all 310

Trending Articles