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

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2077 views
  • 6 likes
  • 4 in conversation