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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 8253 views
  • 2 likes
  • 4 in conversation