BookmarkSubscribeRSS Feed
AIO
Calcite | Level 5 AIO
Calcite | Level 5

I understand that SAS performs arithmetic in a binary system, but I still have following questions about it:

  1. Variable X1 X2: since variable flag="Y", x1 should be less than x2. However, when variable x1 and x2 are displayed as best32. format,  it's "73.75". How could I find the difference directly except using HEXw. format? Is there a way that let X1 display as "73.7499999999999999999999999999999999"?
  2. Variable Z1 Z2: actually, x1 should be less than 73.75. It's specified that "When the value to be rounded is approximately halfway between two multiples of the rounding unit, the ROUND function rounds up the absolute value and restores the original sign" in ROUND function. In this case, it should be 73.7 when I use ROUND function to keep 1 decimal place. However, Z1 is 73.8, why?
  3. ⁠Variable W1 W2: I want to know what's rule when using PUT function to keep the decimal place? Is it "When the value to be rounded is approximately halfway between two multiples of the rounding unit, the ROUND function rounds up the absolute value and restores the original sign"? 
data test;
	x1=(36.9-31)*12.5;
	x2=73.75;
	if x1 <x2 then flag="Y";

	y1=x1;
	y2=x2;
	format x1 x2 best32. y1 y2 hex16.;

	z1=round(x1,0.1);
	z2=round(x2,0.1);

	w1=strip(put(x1,5.1));
	w2=strip(put(x2,5.1));
run;

 

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch 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
  • 0 replies
  • 22 views
  • 0 likes
  • 1 in conversation