BookmarkSubscribeRSS Feed
laurenhosking
Quartz | Level 8
data Exam;
input class grade;
datalines;
0 73
1 86
0 87
1 81
0 78
1 84
0 75
1 88
0 82
1 90
0 66
1 85
0 95
1 84
0 75
1 92
0 70
1 83
1 91
1 53
1 84
;
run;

Im brand new to using SAS University addition and im getting this error. please help as this is done the same as in my booklet provided by the teacher. The code above is my data in a table then below we have the code for the T-test

/*
 *
 * Task code generated by SAS Studio 3.8 
 *
 * Generated on '09/11/2019 15:59' 
 * Generated by 'sasdemo' 
 * Generated on server 'LOCALHOST' 
 * Generated on SAS platform 'Linux LIN X64 2.6.32-754.6.3.el6.x86_64' 
 * Generated on SAS version '9.04.01M6P11072018' 
 * Generated on browser 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362' 
 * Generated on web client 'http://localhost:10080/SASStudio/38/main?locale=en_GB&zone=GMT%252B00%253A00' 
 *
 */

ods noproctitle;
ods graphics / imagemap=on;

/* Test for normality */
proc univariate data=WORK.EXAM normal mu0=0;
	ods select TestsForNormality;
	class grade;
	var class;
run;

/* t test */
proc ttest data=WORK.EXAM sides=L h0=0 plots(showh0);
	class grade;
	var class;
run;

And this is the Log with the error

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 NOTE: ODS statements in the SAS Studio environment may disable some output features.
 73         
 74         /*
 75          *
 76          * Task code generated by SAS Studio 3.8
 77          *
 78          * Generated on '09/11/2019 15:59'
 79          * Generated by 'sasdemo'
 80          * Generated on server 'LOCALHOST'
 81          * Generated on SAS platform 'Linux LIN X64 2.6.32-754.6.3.el6.x86_64'
 82          * Generated on SAS version '9.04.01M6P11072018'
 83          * Generated on browser 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
 83       ! Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362'
 84          * Generated on web client 'http://localhost:10080/SASStudio/38/main?locale=en_GB&zone=GMT%252B00%253A00'
 85          *
 86          */
 87         
 88         ods noproctitle;
 89         ods graphics / imagemap=on;
 90         
 91         /* Test for normality */
 92         proc univariate data=WORK.EXAM normal mu0=0;
 93         ods select TestsForNormality;
 94         class grade;
 95         var class;
 96         run;
 
 NOTE: PROCEDURE UNIVARIATE used (Total process time):
       real time           1.32 seconds
       cpu time            1.30 seconds
       
 
 97         
 98         /* t test */
 99         proc ttest data=WORK.EXAM sides=L h0=0 plots(showh0);
 100        class grade;
 101        var class;
 102        run;
 
 ERROR: The CLASS variable has more than two levels.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE TTEST used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 103        
 104        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 116        

 

6 REPLIES 6
Kurt_Bremser
Super User

@laurenhosking wrote:
data Exam;
input class grade;
datalines;
0 73
1 86
0 87
1 81
0 78
1 84
0 75
1 88
0 82
1 90
0 66
1 85
0 95
1 84
0 75
1 92
0 70
1 83
1 91
1 53
1 84
;
run;

Im brand new to using SAS University addition and im getting this error. please help as this is done the same as in my booklet provided by the teacher

This is my code above


The code you posted is a simple data step to create a dataset and CANNOT be the cause of the ERROR. Please post the code that caused the error message, and the complete log from it.

laurenhosking
Quartz | Level 8

Just changed thank you!

PaigeMiller
Diamond | Level 26

PROC TTEST requires two levels of the class variable.

 

You have in your code

CLASS GRADE; 

and variable GRADE has more than two levels.

--
Paige Miller
Reeza
Super User
As others have indicated you have your usage of CLASS and VAR backwards.
CLASS is the grouping variable and VAR is the variable of the observations you want to see are different. So your CLASS variable is conveniently and confusingly class, and your VAR variable is grade.
Tom
Super User Tom
Super User

You will not get that error from the code you posted.  Please show the code you actually ran that produced the error.

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
  • 6 replies
  • 1914 views
  • 4 likes
  • 5 in conversation