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
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;
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.
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?
this link may assist in your question @GeetVish
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;
@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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.