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

HELP WITH THIS!

Create a temporary SAS data set called birds from this data set:

A Typical -0.255
A Odd -0.324
B Typical -0.213
B Odd -0.185
C Typical -0.190
C Odd -0.299
D Typical -0.185
D Odd -0.144
E Typical -0.045
E Odd -0.027
F Typical -0.025
F Odd -0.039
G Typical -0.015
G Odd -0.264
H Typical 0.003
H Odd -0.077
I Typical 0.015
I Odd -0.017
J Typical 0.020
J Odd -0.169
K Typical 0.023
K Odd -0.096
L Typical 0.040
L Odd -0.330
M Typical 0.040
M Odd -0.346
N Typical 0.050
N Odd -0.191
O Typical 0.055
O Odd -0.128
P Typical 0.058
P Odd -0.182

 

How do I use this 'birds' data set to prepare it for a paired data analysis??

How do I use the TTEST procedure to compare the mean yellowness of the odd and typical feathers?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Try this:

data Birds;
length Group $7;
input ID $ Group Value;
datalines;
A Typical -0.255
A Odd -0.324
B Typical -0.213
B Odd -0.185
C Typical -0.190
C Odd -0.299
D Typical -0.185
D Odd -0.144
E Typical -0.045
E Odd -0.027
F Typical -0.025
F Odd -0.039
G Typical -0.015
G Odd -0.264
H Typical 0.003
H Odd -0.077
I Typical 0.015
I Odd -0.017
J Typical 0.020
J Odd -0.169
K Typical 0.023
K Odd -0.096
L Typical 0.040
L Odd -0.330
M Typical 0.040
M Odd -0.346
N Typical 0.050
N Odd -0.191
O Typical 0.055
O Odd -0.128
P Typical 0.058
P Odd -0.182
;

/* transpose from Long to Wide */
proc transpose data=Birds out=BirdsWide(rename=(COL1=Typical COL2=Odd));
	by Id;
run;

proc ttest data=BirdsWide;
   paired Typical*Odd;
run;

View solution in original post

6 REPLIES 6
Reeza
Super User

Is the file give to you like that or is it a CSV, TXT or Excel file to import?

How to import a data set - VIDEO
https://video.sas.com/detail/videos/sas-analytics-u/video/4664327156001/reading-and-generating-csv-f...

How to read directly via CARDS
https://stats.idre.ucla.edu/sas/modules/inputting-data-into-sas/

How to do a Paired T-Test
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.3/statug/statug_code_tteex03.htm

It seems like you'll need to wrangle your data as well a bit, so instructions on how to that are here. Look at the PROC TTEST example first to see how they structured their data for a paired test.
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/


 

Spoiler

@mpc5 wrote:

HELP WITH THIS!

Create a temporary SAS data set called birds from this data set:

A Typical -0.255
A Odd -0.324
B Typical -0.213
B Odd -0.185
C Typical -0.190
C Odd -0.299
D Typical -0.185
D Odd -0.144
E Typical -0.045
E Odd -0.027
F Typical -0.025
F Odd -0.039
G Typical -0.015
G Odd -0.264
H Typical 0.003
H Odd -0.077
I Typical 0.015
I Odd -0.017
J Typical 0.020
J Odd -0.169
K Typical 0.023
K Odd -0.096
L Typical 0.040
L Odd -0.330
M Typical 0.040
M Odd -0.346
N Typical 0.050
N Odd -0.191
O Typical 0.055
O Odd -0.128
P Typical 0.058
P Odd -0.182

 

How do I use this 'birds' data set to prepare it for a paired data analysis??

How do I use the TTEST procedure to compare the mean yellowness of the odd and typical feathers?

 


ballardw
Super User

@mpc5 wrote:

HELP WITH THIS!

Create a temporary SAS data set called birds from this data set:

A Typical -0.255
A Odd -0.324
B Typical -0.213
B Odd -0.185
C Typical -0.190
C Odd -0.299
D Typical -0.185
D Odd -0.144
E Typical -0.045
E Odd -0.027
F Typical -0.025
F Odd -0.039
G Typical -0.015
G Odd -0.264
H Typical 0.003
H Odd -0.077
I Typical 0.015
I Odd -0.017
J Typical 0.020
J Odd -0.169
K Typical 0.023
K Odd -0.096
L Typical 0.040
L Odd -0.330
M Typical 0.040
M Odd -0.346
N Typical 0.050
N Odd -0.191
O Typical 0.055
O Odd -0.128
P Typical 0.058
P Odd -0.182

 

How do I use this 'birds' data set to prepare it for a paired data analysis??

How do I use the TTEST procedure to compare the mean yellowness of the odd and typical feathers?

 


What are the variable names? Paired on what?

How do we know which variable holds "yellownesss"? You don't say. Such details matter.

mpc5
Calcite | Level 5

variable is bird-feather-yellowness measure

Rick_SAS
SAS Super FREQ

Try this:

data Birds;
length Group $7;
input ID $ Group Value;
datalines;
A Typical -0.255
A Odd -0.324
B Typical -0.213
B Odd -0.185
C Typical -0.190
C Odd -0.299
D Typical -0.185
D Odd -0.144
E Typical -0.045
E Odd -0.027
F Typical -0.025
F Odd -0.039
G Typical -0.015
G Odd -0.264
H Typical 0.003
H Odd -0.077
I Typical 0.015
I Odd -0.017
J Typical 0.020
J Odd -0.169
K Typical 0.023
K Odd -0.096
L Typical 0.040
L Odd -0.330
M Typical 0.040
M Odd -0.346
N Typical 0.050
N Odd -0.191
O Typical 0.055
O Odd -0.128
P Typical 0.058
P Odd -0.182
;

/* transpose from Long to Wide */
proc transpose data=Birds out=BirdsWide(rename=(COL1=Typical COL2=Odd));
	by Id;
run;

proc ttest data=BirdsWide;
   paired Typical*Odd;
run;
mpc5
Calcite | Level 5
16 PROC TTEST DATA = birdswide;
17 TITLE 'Comparison of Birds feathers Yellowness';
18 paired typical*odd;
ERROR: Variable TYPICAL not found.
ERROR: Variable ODD not found.
19 var feather;
ERROR: Variable FEATHER not found.
20 RUN;
StatDave
SAS Super FREQ

Assuming the letters A, B, ... represent individuals, then you have the two values for each individual on separate lines of the data. As noted in the "Student's t-test: two dependent (paired) samples" item in the list of Frequently Asked-for Statistics (FASTats) in the Important Links section of the Statistical Procedures Community page, you can do a paired t-test in PROC UNIVARIATE by analyzing the difference of the paired values and testing that the mean difference is zero. The following computes the difference for each individual and then analyzes it in PROC UNIVARIATE. The test is in the "Tests for Location" table. 

data a;
input id $ type $ y;
retain ty;
if type="Typical" then ty=y;
else diff=ty-y;
if diff ne . then output;
datalines;
A Typical -0.255
A Odd -0.324
B Typical -0.213
B Odd -0.185
C Typical -0.190
C Odd -0.299
D Typical -0.185
D Odd -0.144
E Typical -0.045
E Odd -0.027
F Typical -0.025
F Odd -0.039
G Typical -0.015
G Odd -0.264
H Typical 0.003
H Odd -0.077
I Typical 0.015
I Odd -0.017
J Typical 0.020
J Odd -0.169
K Typical 0.023
K Odd -0.096
L Typical 0.040
L Odd -0.330
M Typical 0.040
M Odd -0.346
N Typical 0.050
N Odd -0.191
O Typical 0.055
O Odd -0.128
P Typical 0.058
P Odd -0.182
;
proc univariate; 
var diff;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 951 views
  • 0 likes
  • 5 in conversation