Help using Base SAS procedures

I'm getting an error about a class. Please help

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

I'm getting an error about a class. Please help

This is the code:

 

data robot;
infile 'C:\Users\paul\Downloads\Robot.dat' dlm=',';
input HumT 1-5 HybT 7-11;
run;
proc univariate data= robot normal;
qqplot HumT /normal (mu=est sigma=est);
by HumT;
run;

proc ttest data=robot sides=2 alpha=0.05 h0=0;
class HumT;
var HybT;
run;

 

The error:

 

ERROR: The CLASS variable has more than two levels.

 

The data:

 

185.4 180.4 .889 .997
146.3 248.5 .791 .959
174.4 185.5 .866 .821
184.9 216.4 .888 .914
240.0 269.3 .916 .973
253.8 249.6 .923 .925
238.8 282.0 .894 .912
263.5 315.9 .934 .965

 

 


Accepted Solutions
Solution
‎04-14-2017 10:47 AM
Super User
Posts: 10,500

Re: I'm getting an error about a class. Please help

Your classification variable should have values of Human and Hybrid to compare the mean score for throughput and quality.

Please see:

data have;
   input HumT HybT HumQ HybQ;
datalines;
185.4 180.4 .889 .997
146.3 248.5 .791 .959
174.4 185.5 .866 .821
184.9 216.4 .888 .914
240.0 269.3 .916 .973
253.8 249.6 .923 .925
238.8 282.0 .894 .912
263.5 315.9 .934 .965
;
run;

data need;
   set have;
   length type $6.;
   Type = 'Human';
   Throughput = Humt;
   Quality = HumQ;
   output;
   Type = 'Hybrid';
   Throughput = HybT;
   Quality = HybQ;
   output;
   keep type Throughput Quality;
run;

proc ttest data=need;
   class type;
   var Throughput Quality;
run;

View solution in original post


All Replies
Super User
Posts: 5,084

Re: I'm getting an error about a class. Please help

By design, a t-test compares two groups.  That has nothing to do with SAS, it's just what a t-test does.  So your CLASS variable within PROC TTEST should only take on two values.

 

What are you trying to accomplish, given that you have a data st with many values not two?

Contributor
Posts: 21

Re: I'm getting an error about a class. Please help

I'm trying to compare if humans and hybrid differ for

  1. Throughput
  2. Quality
  1. Variable

Columns

Human throughput

1-5

hybrid throughput

7-11

Human quality

13-16

Hybrid quality

18-21

 

Super User
Posts: 5,084

Re: I'm getting an error about a class. Please help

I believe you will need to structure your data differently for that.  For example, you could read it in this way:

 

data robot;
infile 'C:\Users\paul\Downloads\Robot.dat' dlm=',';

idnum = _n_;

category='Hybrid';
input throughput 7-11 quality 18-21 @ ;

output;

category='Human';

input throughput 1-5 quality 13-16;

output;
run;

185.4 180.4 .889 .997
146.3 248.5 .791 .959
174.4 185.5 .866 .821
184.9 216.4 .888 .914
240.0 269.3 .916 .973
253.8 249.6 .923 .925
238.8 282.0 .894 .912
263.5 315.9 .934 .965

;

 

It's not clear whether you would need idnum later on, so I included it.  It lets you match up the human vs. hybrid observations.

Contributor
Posts: 21

Re: I'm getting an error about a class. Please help

Will you please take a look at the rest of the code. I can get it to work. Is this correct?
proc univariate data= robot normal;
qqplot HumT /normal (mu=est sigma=est);
by HumT;
run;

proc ttest data=robot sides=2 alpha=0.05 h0=0;
class HumT;
var HybT;
run;

Solution
‎04-14-2017 10:47 AM
Super User
Posts: 10,500

Re: I'm getting an error about a class. Please help

Your classification variable should have values of Human and Hybrid to compare the mean score for throughput and quality.

Please see:

data have;
   input HumT HybT HumQ HybQ;
datalines;
185.4 180.4 .889 .997
146.3 248.5 .791 .959
174.4 185.5 .866 .821
184.9 216.4 .888 .914
240.0 269.3 .916 .973
253.8 249.6 .923 .925
238.8 282.0 .894 .912
263.5 315.9 .934 .965
;
run;

data need;
   set have;
   length type $6.;
   Type = 'Human';
   Throughput = Humt;
   Quality = HumQ;
   output;
   Type = 'Hybrid';
   Throughput = HybT;
   Quality = HybQ;
   output;
   keep type Throughput Quality;
run;

proc ttest data=need;
   class type;
   var Throughput Quality;
run;
Contributor
Posts: 21

Re: I'm getting an error about a class. Please help

it worked, Thank you!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 141 views
  • 1 like
  • 3 in conversation