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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 1543 views
  • 1 like
  • 3 in conversation