Hi @chinna0369,
@chinna0369 wrote:
I am using "chk=put(mean,8.2);" but still I am getting 5.42 instead of 5.43. is there anything wrong with my SAS?
No, this can easily happen due to numeric representation issues, i.e. small rounding errors that make numeric values different from what they look like in common display formats.
Example:
data test;
mean=mean(-4.19, 15.04);
true_mean=round(mean,1e-9);
chk=put(mean,8.2);
true_chk=put(true_mean,8.2);
put mean hex16.;
put true_mean hex16.;
run;
proc print data=test noobs;
run;
Log:
1185 put mean hex16.;
1186 put true_mean hex16.;
1187 run;
4015B33333333332
4015B33333333333
Output:
true_
mean mean chk true_chk
5.425 5.425 5.42 5.43
This is exactly what you observed, although mathematically the mean of -4.19 and 15.04 is, of course, 5.425, which is displayed as 5.43 with format 8.2, but not if the internal value is slightly less than 5.425 because of rounding errors (see log excerpt above).
In the above example even the BEST18. format reveals the rounding error in variable MEAN, but this is not always the case.