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

I am receiving the error that says the class variable has more than two levels, but i am pretty sure i only have two. Please help.

 

 

PROC IMPORT DATAFILE=REFFILE
DBMS=CSV
OUT=WORK.IMPORT;
GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.IMPORT; RUN;


%web_open_table(WORK.IMPORT);


DATA IMPORT;
infile '/folders/myfolders/sasuser.v94/nyc-rolling-sales.csv';
INPUT NEIGHBORHOOD $ Sales_Price;

proc ttest;

class neighborhood; /* defines the grouping variable */

var sales_price; /* variable whose means will be compared */

run;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

... then use

 

proc ttest data=import;
/* Neighborhoods values to be compared */
where neighborhood in ("First value", "Second value");
class neighborhood;
var sales_price; /* variable whose means will be compared */
run;

to compare the levels of interest.

PG

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

Run this to confirm how many levels:

 

proc freq;
table neighborhood / missing;
run;
PGStats
Opal | Level 21

... then use

 

proc ttest data=import;
/* Neighborhoods values to be compared */
where neighborhood in ("First value", "Second value");
class neighborhood;
var sales_price; /* variable whose means will be compared */
run;

to compare the levels of interest.

PG
abudyak
Calcite | Level 5

I am getting the same error. I am having trouble posting my question. Why do I keep getting the error "the class variable has more than two levels"?

 

My code:

data name;
	input one two @@;
	cards;
	16.03 16.02 16.04 15.97 16.05 15.96 16.05 16.01 16.02 15.99
	16.01 16.03 15.96 16.04 15.98 16.02 16.02 16.01 15.99 16.00
	;
proc ttest data=name;
	class one;
	var two;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 9163 views
  • 2 likes
  • 4 in conversation