hi,
my enterprise guide do not have sas/stat licence so proc ttest is not working, is there another procedure for two sample t-test. You can give the codes from testscores data. Thanks.
By the way it is very annoying that one programme has many packages, we are trying to learn a programme here, everytime another obstacle comes along.
Hi @chinaski,
SAS University Edition includes SAS/STAT among other modules, so this would be a great option for learning purposes.
Otherwise, the two-sample t-test is simple enough to implement the formulas found in the documentation in SAS/Base code.
Example including mean difference, pooled standard error, t-statistic and two-sided p-value:
proc summary data=sashelp.class nway;
class sex;
var height;
output out=stats n=n mean=m std=s;
run;
data want(keep=d se t p);
set stats;
if _n_=1 then do; m1+m; n1+n; s1+s; end;
else do;
d=m1-m;
se=sqrt(((n1-1)*s1**2+(n-1)*s**2)/(n1+n-2)*(1/n1+1/n));
t=d/se;
p=1-probf(t**2,1,n1+n-2);
output;
end;
format p pvalue.;
run;
Result:
d se t p -3.32111 2.28628 -1.45263 0.1645
For comparison:
proc ttest data=sashelp.class;
class sex;
var height;
run;
Partial output (relevant numbers highlighted):
The TTEST Procedure Variable: Height Sex Method N Mean Std Dev Std Err Minimum Maximum F 9 60.5889 5.0183 1.6728 51.3000 66.5000 M 10 63.9100 4.9379 1.5615 57.3000 72.0000 Diff (1-2) Pooled -3.3211 4.9759 2.2863 Diff (1-2) Satterthwaite -3.3211 2.2883 Sex Method Mean 95% CL Mean Std Dev 95% CL Std Dev F 60.5889 56.7315 64.4463 5.0183 3.3897 9.6140 M 63.9100 60.3776 67.4424 4.9379 3.3965 9.0147 Diff (1-2) Pooled -3.3211 -8.1447 1.5025 4.9759 3.7339 7.4596 Diff (1-2) Satterthwaite -3.3211 -8.1551 1.5129 Method Variances DF t Value Pr > |t| Pooled Equal 17 -1.45 0.1645
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.