Help using Base SAS procedures

precision of analysis variable of proc tabulate

Reply
N/A
Posts: 0

precision of analysis variable of proc tabulate

precision of analysis variable of proc tabulate

Please tell me the trick please^^

I would like to display truncation of 2 decimal places in a table
i.e.
2.8888

2.88 will be shown

--------------------------------------------
if I use
f = 8.2
2.89 will be displayed......that is I dont want
--------------------------------------------
Super Contributor
Super Contributor
Posts: 3,174

Re: precision of analysis variable of proc tabulate

Posted in reply to deleted_user
SAS numeric formats round - the CEIL, FLOOR and ROUND functions can influence this behavior with pre-processing in a DATA step, otherwise you can display the value as formatted with your own defined PROC FORMAT (using PICTURE). A link to a SAS conference paper is provided below, as well as having SAS-hosted documentation at the SAS support http://support.sas.com/ website and other technical papers available using the SEARCH facility.

Scott Barry
SBBWorks, Inc.

Getting in to the Picture (Format)
Andrew H. Karp, Sierra Information Services, Sonoma, CA USA
http://www2.sas.com/proceedings/sugi31/243-31.pdf
N/A
Posts: 0

Re: precision of analysis variable of proc tabulate

Thanks for your reply
I have tried proc format picture and it works successfully on
proc print
The Class variable on proc tabulate

However, i have no idea in applying the syntax on
analysis variable "var"

If I would like to display the mean with rounded 2 decimal places (mean * f=8.2)

How can I
display the mean with roundDOWN 2 decimal places (mean * f=????)

Thanks
Valued Guide
Posts: 2,177

Re: precision of analysis variable of proc tabulate

Posted in reply to deleted_user
To demonstarte data with more decimal places than monber, suppose we create data like bmi on sashelp.class
As I don't know the unit conversion, the following is just approximately "logical"
[pre]data classb ;
set sashelp.class ;
myBMI = height**3 / weight ;
run ;
proc format ;
picture truncat .=. other = '00001.23'(mult=100) ;
proc tabulate ;
class age ;
var myBMI ;
table ( all age all ), n*f=3. mybmi*(mean='trunc'*f=truncat.
mean='round'*f=8.2
mean='more-'*f=11.5)
/rts=10 ;
run ; [/pre]It is tested in SAS9.2 but would probably run in SAS6
run that and see if it demonstrates the truncation required

There is an option for numeric user formats to round before formatting. That feature is not used in my example, above.

PeterC
N/A
Posts: 0

Re: precision of analysis variable of proc tabulate

Thank you very much!
I got the idea now!
Ask a Question
Discussion stats
  • 4 replies
  • 155 views
  • 0 likes
  • 3 in conversation