BookmarkSubscribeRSS Feed
chinaski
Obsidian | Level 7

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.

1 REPLY 1
FreelanceReinh
Jade | Level 19

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 1 reply
  • 297 views
  • 3 likes
  • 2 in conversation