BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
--------------------------------------------
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
deleted_user
Not applicable
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
Peter_C
Rhodochrosite | Level 12
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
deleted_user
Not applicable
Thank you very much!
I got the idea now!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1401 views
  • 0 likes
  • 3 in conversation