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
Opal | Level 21

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
Opal | Level 21

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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