BookmarkSubscribeRSS Feed
gauravv0103
Calcite | Level 5

Please find attached a file (XrA 16-05.xls) on which I have tried 2 sample ttest with the below mentioned code

 

ods noproctitle;
ods graphics / imagemap=on;

/* t test */
proc ttest data=WORK.SYMPTOMS sides=2 h0=0 cochran plots(only
showh0)=(summaryPlot intervalPlot qqplot);
class Home;
var Outside;
run;

 

For both the variables in the sheet if I choose it as class (as one by one case) the log shows

ERROR: The CLASS variable has more than two levels.

Also I am not getting the T value and p value, QQ plot etc

 

Can some one please help as I faced the same situation with another file as well.

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Hello, @gauravv0103 welcome to the SAS Communities.

 

ERROR: The CLASS variable has more than two levels.

 

Your CLASS variable named HOME has more than two levels, and so you cannot perform PROC TTEST on it. You need to use a variable that has exactly two levels (or perform your t-tests in PROC GLM).

--
Paige Miller
gauravv0103
Calcite | Level 5

Thanks Mr. Miller for your input and suggestion.

 

Just wanted to understand what do we mean regarding levels over here, It is a generic numeric variable we are getting the solution we when we run it through either excel data analysis or use Minitab. Then why it is not possible with Proc ttest.

 

Request if you could throw light on it.

gauravv0103
Calcite | Level 5

Mr. Miller, As advised by you I have used Proc GLM for the same but the results are not matching with excel data analysis.

 

I have used the following procedure, please let me know if it is the right way to do it.

ods graphics on;
proc glm data=wives plot=diagnostics;
class Home;
model Outside = Home;
run;
ods graphics off;

 

Also attached is the outcome of GLM ( it is giving F Value) in PDF format and excel data analysis (It is giving T Value). How can we conclude that both results in same analysis.

 

Regards

 

PaigeMiller
Diamond | Level 26

@gauravv0103 wrote:

 

Just wanted to understand what do we mean regarding levels over here, It is a generic numeric variable we are getting the solution we when we run it through either excel data analysis or use Minitab. Then why it is not possible with Proc ttest.


Numeric variables are almost never placed in CLASS statements in PROC TTEST. The CLASS statement should contain the name of a category variable that contains two levels. "Generic numeric" variables probably ought to go in the VAR statement.

--
Paige Miller

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2100 views
  • 0 likes
  • 2 in conversation