BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
maragdalis
Calcite | Level 5

Hi I want to produce a table that has the frequency of males and females by age group and bmi group and the 95%conf interval for bmi within each group. 

 ie 

--------------------------------------------------------------

Sex         | underweight | normal | overweight | obese     |

--------------------------------------------------------------

|M Freq |    5                  |   10          |      8              |    5            |

--------------------------------------------------------------

| 95%CI|   15.1-18.0       | 19.1-20.5|   26.2-29.1   | 36.9-41.1 |

etc

 

many thanks in advanced

 

PROC FORMAT;
VALUE agefmt
20-<30 = '20-<30 years'
30-<40 = '30-<40 years'
40-<50 = '40-<50 years'
;
value bmifmt
9-<18.5 = 'Underweight (9-<18.5)'
18.5-<25 = 'Healthy (18.5-<25)'
25-<30 = 'Overweight (25-<30)'
30-51 = 'Obese (30+)';
VALUE sexfmt
0 = 'Female'
1 = 'Male'
;
RUN;

DATA have;
INPUT age bmi sex @@;
DATALINES;
20 18.5 1 25 23.5 1 26 24.5 1 20 15.5 1 20 16.2 1 21 18.0 1 20 30.2 1 21 26.5 1 22 29.0 1 22 29.5 1
20 22.5 0 21 23.5 0 20 24.5 0 23 25.5 0 23 25.2 0 25 19.0 0 26 38.2 0 23 36.5 0 24 29.0 0 25 16.5 0
30 22.5 0 31 23.5 0 30 24.5 0 33 25.5 0 33 25.2 0 35 19.0 0 36 38.2 0 33 36.5 0 34 29.0 0 35 16.5 0
30 18.5 1 35 20.5 1 36 24.5 1 30 15.5 1 30 16.2 1 31 18.0 1 30 30.2 1 31 26.1 1 32 29.1 1 32 29.5 1
40 22.5 0 40 23.5 0 40 24.5 0 42 25.5 0 42 20.2 0 45 39.0 0 46 38.2 0 43 36.5 0 44 29.0 0 45 30.5 0
40 12.5 1 41 28.5 1 40 24.5 1 43 25.5 1 43 25.2 1 45 19.0 1 46 38.2 1 43 36.5 1 44 29.0 1 45 16.5 1
;

DATA want;
SET have;
FORMAT age agefmt.;
FORMAT bmi bmifmt. ;
FORMAT sex sexfmt.;

RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
whymath
Lapis Lazuli | Level 10

Use a class statement to divide data into different group:

proc means data=want n mean std clm;
  class sex age bmi;
  var bmi;
run;

View solution in original post

2 REPLIES 2
whymath
Lapis Lazuli | Level 10

Use a class statement to divide data into different group:

proc means data=want n mean std clm;
  class sex age bmi;
  var bmi;
run;
PaigeMiller
Diamond | Level 26

@maragdalis wrote:

Hi I want to produce a table that has the frequency of males and females by age group and bmi group and the 95%conf interval for bmi within each group. 

 

I think it would be helpful to be technical for a second. You cannot produce "confidence intervals for BMI", there is no such thing. There are confidence intervals for a statistic computed from BMI such as confidence intervals of the mean of BMI. From now on, for your own benefit as well as for the benefit of your audience, you should probably refer to "confidence intervals for the mean of BMI" and not "confidence intervals for BMI". 

 

Is that what you want, confidence intervals for the mean of BMI? Since you do not show the mean in your table, I find this very confusing. Wouldn't including the mean in your table be a good thing to do?

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 880 views
  • 1 like
  • 3 in conversation