While running proc ttest I've noticed SAS returns the same sample size (N) values for my class variable whether I'm using weights or no weights (see code below).
In my data the Treatment records all have inv_weight = 1 while the Control records have inv_weight between values between 0 and 1.
Note that the mean and stnd deviation statistics for the Controls differ for weighted/unweighted proc ttest.
I'm assuming SAS is correctly performing the weighted t-test but for whatever reasons outputs the unweighted N counts?
proc ttest data=&bcbsri order=data;
class class;
var er_bsln_ptmpy;
weight inv_weight;
run;
/*
The TTEST Procedure
Variable: er_bsln_ptmpy
Weight: inv_weight
class N Mean Std Dev Std Err Minimum Maximum
Treatment 703 1147.9 1975.1 74.4936 0 26000.0
Control 1183962 843.6 418.0 1.2572 0 20000.0
Diff (1-2) 304.4 420.6 15.9142
class Method Mean 95% CL Mean Std Dev 95% CL Std Dev
Treatment 1147.9 1001.7 1294.2 1975.1 1877.0 2084.2
Control 843.6 841.1 846.0 418.0 417.5 418.5
Diff (1-2) Pooled 304.4 273.2 335.5 420.6 420.1 421.2
Diff (1-2) Satterthwaite 304.4 158.1 450.6
Method Variances DF t Value Pr > |t|
Pooled Equal 1.18E6 19.12 <.0001
Satterthwaite Unequal 702.4 4.09 <.0001
Equality of Variances
Method Num DF Den DF F Value Pr > F
Folded F 702 1.18E6 22.33 <.0001
*/
proc ttest data=&bcbsri order=data;
class class;
var er_bsln_ptmpy;
/* weight inv_weight;*/
run;
/*
The TTEST Procedure
Variable: er_bsln_ptmpy
class N Mean Std Dev Std Err Minimum Maximum
Treatment 703 1147.9 1975.1 74.4936 0 26000.0
Control 1183962 753.7 1370.1 1.2592 0 20000.0
Diff (1-2) 394.2 1370.6 51.7069
class Method Mean 95% CL Mean Std Dev 95% CL Std Dev
Treatment 1147.9 1001.7 1294.2 1975.1 1877.0 2084.2
Control 753.7 751.2 756.2 1370.1 1368.4 1371.9
Diff (1-2) Pooled 394.2 292.9 495.6 1370.6 1368.8 1372.3
Diff (1-2) Satterthwaite 394.2 248.0 540.5
Method Variances DF t Value Pr > |t|
Pooled Equal 1.18E6 7.62 <.0001
Satterthwaite Unequal 702.4 5.29 <.0001
Equality of Variances
Method Num DF Den DF F Value Pr > F
Folded F 702 1.18E6 2.08 <.0001
*/
PROC TTEST is correct. Weights do not affect Ns. The FREQ statement affects Ns.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.