03-25-2015 09:39 AM
I have a quite simple beginners question:
Lets consider the following data set:
Input ID Number Name $ Age;
1 214 Hans 20
2 215 Peter 22
3 210 Gustav 24
4 209 Elvira 55
5 208 Ivonne 60
6 206 Claire 62
I created a age class variable like this:
if age<42 then ageclass=1;
(please do not post a comment if this is a good idea or not, this is not my question).
Now I want to analyze it in the following way:
proc means data=temporary maxdecs=2;
In the results e.g. in the mean column there are values such as 59.00 and 22.00. It is correct that I want to have two digits, so e.g. 3.61 makes sense for me. However, I do not like that sas displayes two .00 where it is not necessary. So for the values with .00 I would like to have a simple rounding, so that simply 59 and 22 are displayed, but I do not want the 3.61 to be rounded.
How can I achieve this?
Thanks a lot for your help!
03-25-2015 10:54 AM
Send the output to a data set and use another procedure to display the results. In that procedure associate a format like BEST5.2; If the value is integer it will not display decimals, if there are 2 or more decimals it will only display a maximum of 2.
If only one decimal that is all that would display so if you expect 3.20 to appear it won't.
03-25-2015 11:28 AM
With 9.3 and running a few variations of the number of decimals in the value of x in this program:
put x= best5.2;
Those were the results displayed in the log.
03-25-2015 11:42 AM
It doesn't show 2 decimal places. Is that what you think it should do?
03-25-2015 05:10 PM
I hate when I try something and accidentally pick an example that doesn't pick up what I wanted, which I would have gotten wth best6. Thanks for reminder.
03-25-2015 11:45 AM
I feel it is better to use proc tabulate like this..
Proc tabulate data=temporary;
table ageclass, age*(n mean*f=bestd6.2 ); run;
Using the formar bestd6.2
This should work. !