Hey Everyone!
New SAS user here and I'm hoping you can help me solve a problem. In brief, I have a dataset where I need to compare the mean weight of two species of mouse. Moreover, I'm not simply testing whether or not they're different but rather, does the difference of their mean weight exceed 7 grams? Symbolically, my hypotheses may be stated as:
Ho: |µ1 - µ2| ≤ 7 or µD ≤ 7
Ha: |µ1 - µ2| > 7 or µD > 7
My question is, how do I translate this into SAS code? I found some documentation about the H0 option in proc ttest but I'm unsure about whether I've implemented it correctly for a two-sided test and I'm definitely unsure on how to ask a 1-sided question.
At present my code looks something like:
data weight;
input species_1 species_2;
cards;
22 36
18 24
23 34
22 24
14 37
15 34
;
run;
data weight2;
set weight;
weight = species_1;
species = 1;
output;
weight = species_2;
species = 2;
output;
drop species_1 species_2;
run;
proc sort data=weight2;
by species;
run;
proc ttest data=weight2 H0 = 7;
class species;
var weight;
run;
Any advice you all can offer would be much appreciated!
Thank you in advance!
Hey, thank you for the quick reply! Seems like SIDES should do the trick but I do still have one concern.
My hypotheses concern the absolute difference between groups. The sample of my data above yields a mean difference of -12.5 if the default is µ1 - µ2 is used. If µ2-µ1 is used, this flips and becomes 12.5. How do I account for my case where I'm seeking to look at the absolute difference?
I just tried an alternative method. Does this look like it should adequately address my hypothesis?
data weight;
input species_1 species_2;
cards;
22 36
18 24
23 34
22 24
14 37
15 34
;
run;
data weight2;
set weight;
weight = species_1;
species = 1;
output;
weight = species_2;
species = 2;
output;
drop species_1 species_2;
run;
data weight_diff;
set weight;
weight_diff = abs(species_1 - species_2);
run;
proc ttest data=weight_diff H0 = 7 SIDES=U;
var weight_diff;
run;
@stats_novice_44 wrote:
My hypotheses concern the absolute difference between groups.
Then that doesn't sound like a one sided test to me.
Well it's one-sided in that I'm trying to determine if the difference between means exceeds my value of interest, in this case 7.
Does |µ1 - µ2| exceed 7?
From your interest in the differences, I assume that your data is paired data, and your hypothesis sounds like an equivalence sort of test is desired. You probably need to use the TOST option in the PROC TTEST statement and the PAIRED statement with your original data arrangement with two response variables. See the example titled "Equivalence Testing with Lognormal Data" in the TTEST documentation - it involved lognormal data, but that is not required.
If you think of this as a non-inferiority test, I think the following may be of interest:
proc ttest data=weight2 h0=-7 sides=L;
class species;
var weight;
run;
This uses your 'long' dataset. The output shows that the difference is significantly less than -7.
SteveDenham
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.