- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
this link may assist in your question @GeetVish
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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