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

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

6 REPLIES 6
Astounding
PROC Star

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?

pacruz
Calcite | Level 5

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

 

Astounding
PROC Star

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.

pacruz
Calcite | Level 5
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;

ballardw
Super User

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;
pacruz
Calcite | Level 5

it worked, Thank you!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 2055 views
  • 1 like
  • 3 in conversation