BookmarkSubscribeRSS Feed
lgooseberry
Calcite | Level 5

I keep receiving the error: 

Proc means data= bmi_smoke mean stddev;
89 class BMI;
90 by sex;
91 Run;
 
ERROR: Data set WORK.BMI_SMOKE is not sorted in ascending sequence. The current BY group has sex = 2 and the next BY group has sex
= 1.
 
 
i'm just trying to figure out how to get the mean and standard deviation of the BMI by sex.
 
any ideas? 
3 REPLIES 3
Shmuel
Garnet | Level 18

Precede your code by proc sort:

proc sort data=bmi_smoke ;
 by sex bmi;
run;
Tom
Super User Tom
Super User

Sounds like you want BMI on the VAR statement.  Put SEX on the CLASS statement, instead of trying to use a BY statement.

proc means data= bmi_smoke mean stddev;
  class sex;
  var BMI; 
run;
lgooseberry
Calcite | Level 5

thanks Tom! that helped! do you know if i am able to find out the 95% confidence interval level in that code as well? 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1111 views
  • 0 likes
  • 3 in conversation