BookmarkSubscribeRSS Feed
dariatri
Calcite | Level 5

Hi,

I'd be happy to receive help 🙂

That's my code: 

 

proc tabulate data=people (where=(SAFFL='Y'));
var AGE weight height BMI;
table AGE='Age [years]' weight='Weight [kg]' height='Height [cm]' BMI='BMI [kg/m2]', (mean*f=8.1 std*f=8.1 (min median max n)*f=8.)/box='Parameters';
run;

 

I only need the BMI var statistics to be in 8.1 format and the rest in 8.0. I'm not able to do that. The only way I can think of is to create a separate table for BMI and somehow combine them.  Is it possible to do it in the above code?

 

Thank You!!

2 REPLIES 2
pink_poodle
Barite | Level 11

You might need to associate the 8.1 format with the variable name (BMI) in addition to the statistic keyword.

Use the asterisk (*) operator to associate a statistic keyword with a variable. The N statistic (number of nonmissing values) can be specified in a dimension expression without associating it with a variable. [1]

This might work. 

table 
AGE='Age [years]'
weight='Weight [kg]'
height='Height [cm]'
BMI='BMI [kg/m2]',
(BMI*mean*f=8.1 BMI*std*f=8.1 (min median max n)*f=8.)
/box='Parameters'; run;

Also, try enclosing the stat names in quotation marks:

 Statistical keywords should be enclosed by single or double quotation marks to ensure that the keyword element is treated as a statistical keyword and not treated as a variable [1].

 

Reference

 

[1] TABULATE Procedure: keywords for statistics in dimension expressions

 

ballardw
Super User

@dariatri wrote:

Hi,

I'd be happy to receive help 🙂

That's my code: 

 

proc tabulate data=people (where=(SAFFL='Y'));
var AGE weight height BMI;
table AGE='Age [years]' weight='Weight [kg]' height='Height [cm]' BMI='BMI [kg/m2]', (mean*f=8.1 std*f=8.1 (min median max n)*f=8.)/box='Parameters';
run;

 

I only need the BMI var statistics to be in 8.1 format and the rest in 8.0. I'm not able to do that. The only way I can think of is to create a separate table for BMI and somehow combine them.  Is it possible to do it in the above code?

 

Thank You!!


Easiest may be to use two table statements (you can have many table statements in proc tabulate).

proc tabulate data=people (where=(SAFFL='Y'));
var AGE weight height BMI;
table AGE='Age [years]' 
      weight='Weight [kg]' 
      height='Height [cm]' ,
     (mean*f=8.0 std*f=8.0 (min median max n)*f=8.0)
     /box='Parameters';
table BMI='BMI [kg/m2]', 
     (mean*f=8.1 std*f=8.1 (min median max n)*f=8.1)
     /box='Parameters';
run;

if I understand what you want.

 

The other approach would be to presummarize the data with a procedure such as Proc Means/Summary, possibly transpose and/or round the results as desiredthen use proc Print or Report to display the values with best. format

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 925 views
  • 0 likes
  • 3 in conversation