How to derive subgroup adjusted outcome averages and conduct pairwise stat-test

When you run a statistical interaction model (e.g., Y=TREATMENT + GENDER + TREATMENT*GENDER), you also want to run a mathematically equivalent model: Y= T_MALE + C_MALE + T_FEMALE + C_FEMALE.

SUBGROUP defines the four groups below.

This is for linear model (HLM because I have the random statement).

proc glimmix data=asdf3 namelen=32; class […]

Odds ratio using PROC MEANS and a data step

proc means data=amy stackodsoutput mean min max n; class A B; var X ; ods output summary=kaz_mean; run;

proc transpose data=kaz_mean out=amyt; by B; var Mean;run;

data amyt2; set amyt; /*http://en.wikipedia.org/wiki/Odds_ratio test using the set values. This should return odds ratio of 36 col1=0.9; col2=0.2; */

odds_ratio= ( col2/(1-col2)) /(col1/(1-col1)) ;

run;

T-test for proportions of multiple groups using SAS procedures and datasteps

/*In this example, there is only two groups, but you can run it with multiple groups.*/

data kaz;set sashelp.class; if age < 12 then THIS_IS_OUTCOME=0; if age > 13 then THIS_IS_OUTCOME=1;

run;

%let group=sex; %let outcome=THIS_IS_OUTCOME; %let dataname=kaz;

ods listing; ods trace on;

proc means data=&dataname; where &outcome ne .; class &group; var &outcome; […]

Appling t-test for comparison of proportion in a data step:

 

 

%let var1=female;

%let var2=male;

%let key=ENROLL_RATE;

Z=(&var1._&key-&var2._&key)/(SQRT((&var1._&key*(1-&var1._&key)/&var1._SAMPLE_N )+&var2._&key*(1-&var2._&key)/ &var2._SAMPLE_N ));

 

 

data &schoollevel.&var1; retain group; merge ueka1b ueka2b; by group;

P1=M2_MET_pre_Mean; P2=M2_MET_post1_Mean;

N1=M2_MET_pre_N; N2=M2_MET_post1_N;

A=(P1*(1-P1))/N1; B=(P2*(1-P2))/N2; STDERR=sqrt(A+B);

Z=abs((P1-P2)/STDERR); /*two tail 5%*/

P=(1-probnorm(Z))*2;

if P < 0.05 then SIG="*";

drop A B P1 P2 N1 N2; run;