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

PROC TTEST DATA = HEART;

CLASS WEIGHT_STATUS;

VAR CHOLESTROL;

RUN;

  i AM GETTING AN ERROR SAYING CLASS HAS MORE THAN 2 LEVELS. i AM VERY NEW TO PROC TTEST, ANOVA , GLM ETC. i WAS PRACTICING IT AND FOUND THIS ERROR. i ACTUALLY CHECKED FOR MISSING VALUES TOO. CAN YOU PPLEASE GUIDE 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @GeetVish and welcome to the SAS Support Communities!

 

Try something like this:

 

proc ttest data = sashelp.heart;
where weight_status in ('Normal', 'Overweight');
class weight_status;
var cholesterol;
run;

I restricted weight_status to those two levels which seemed most interesting to me in view of the results of the PROC FREQ step below:

proc freq data=sashelp.heart;
tables weight_status;
run;

 

 

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

If you are getting an error that says you have more than two levels, then the conclusion is obvious, your data used in PROC TTEST has more than two levels.

 

You need to examine the data set you are using, and you will see that there are more than two levels for the variable WEIGHT_STATUS.

 

Please DO NOT TYPE YOUR ENTIRE MESSAGE IN ALL CAPITALS. Use proper English mixed case. Thank you.

--
Paige Miller
GeetVish
Calcite | Level 5

ok thanks , i am very new to this blog too. Thanks anyways .I will check.

Can you tell me how to check the levels? what is level?

FreelanceReinh
Jade | Level 19

Hello @GeetVish and welcome to the SAS Support Communities!

 

Try something like this:

 

proc ttest data = sashelp.heart;
where weight_status in ('Normal', 'Overweight');
class weight_status;
var cholesterol;
run;

I restricted weight_status to those two levels which seemed most interesting to me in view of the results of the PROC FREQ step below:

proc freq data=sashelp.heart;
tables weight_status;
run;

 

 

PaigeMiller
Diamond | Level 26

@GeetVish wrote:

ok thanks , i am very new to this blog too. Thanks anyways .I will check.

Can you tell me how to check the levels? what is level?


If you don't know what a level is, how can you even consider doing a T-test? That's what a t-test does, it compares the means of two different levels (conditions, settings, etc.) of a variable (in this case WEIGHT_STATUS) in your data.

 

You can check the levels in any number of ways; by doing a PROC PRINT or a PROC FREQ on the variable WEIGHT_STATUS. It is also a very good idea to learn how to view your data to debug problems by viewing your data using the viewtable feature in SAS.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 5 replies
  • 2510 views
  • 6 likes
  • 4 in conversation