Two sample T test using summarized data
Source:    Publish Time: 2013-04-07 04:45   3754 Views   Size:  16px  14px  12px
Author: Xuanqian Xie The SAS Macro was developed to estimate the p value and 95%CI of difference in means for two sam

Author: Xuanqian Xie

The SAS Macro was developed to estimate the p value and 95%CI of difference in means for two samples with summarized data (without individual level data). The example was taken from Lorente et al 2007.

/*Two sample T test using summarized data: small samples and equal SDs*/

%macro ttest (n1=, x1_bar=, s1=, n2=, x2_bar=, s2=, pr=);

Data _null_;

/*s=sqrt((n1-1)*s1*s1+(n0-1)*s0*s0)/(n1+n0-2))*/

/*se=s*sqrt(1/n1+1/n0)*/

/*T=(X1_bar-X0_bar)/se*/

sq=((&n1-1)*(&s1*&s1)+(&n2-1)*(&s2*&s2))/(&n1+&n2-2) ;

se= sqrt(sq*(1/&n1+ 1/&n2)) ;

T= abs ((&X1_bar-&X2_bar)/se);

df=&n1+&n2-2;

P_value=(1-probt(T,df))*2;

t_value = tinv(1-(&pr/2),df);

low_95 =(&x2_bar-&x1_bar)- t_value* se;

high_95=(&x2_bar-&x1_bar)+ t_value* se;

mean_diff_CL=trim(left(put((&x2_bar-&x1_bar), 8.2)))||" ("||trim(left(put(low_95, 8.2)))||", "||trim(left(put(high_95, 8.2)))||")";

put "sq=" sq  ";"  "  se=" se ";"  "  T=" T  ";" "  t_value=" t_value;

put " ";

put "mean_diff_CL=" mean_diff_CL  ";"  "  P_value=" P_value;

run;

%mend;

/*P calue for Metz, 1998*/

%ttest (n1=10, x1_bar=5.1, s1=0.8755950 , n2=5, x2_bar=4.4 , s2= 1.1401754, pr=0.05 );

sq=0.9307691698 ;  se=0.5284228902 ;  T=1.3246965885 ;  t_value=2.1603686565

mean_diff_CL=-0.70 (-1.84, 0.44) ;  P_value=0.2080872953

Reference:

Metz C, Linde H-J, Gobel L, Gobel F, Taeger K. Influence of intermittent subglottic lavage on subglottic colonisation and ventilator-associated pneumonia. Clinical Intensive Care 1998; 9(1):20-24.

 Prev articleÔºöHypothesis test comparing the sample proportion with the population proportionNext articleÔºöNo next article