Resources

Documentation Example 13 for PROC MIANALYZE

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: MIANAX13                                            */
/*   TITLE: Documentation Example 13 for PROC MIANALYZE         */
/* PRODUCT: STAT                                                */
/*  SYSTEM: ALL                                                 */
/*    KEYS: multiple imputation                                 */
/*   PROCS: MI, MIANALYZE, REG                                  */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT: Yang Yuan             UPDATE: Jan 4, 2013           */
/*     REF: PROC MIANALYZE, EXAMPLE 13                          */
/*    MISC:                                                     */
/****************************************************************/

data Mono2;
   do Trt=0 to 1;
   do j=1 to 5;
      y0=10 + rannor(99);
      y1= y0 + 0.75*Trt + rannor(99);
      if (ranuni(99) < 0.3) then y1=.;
      output;
   end; end;
   do Trt=0 to 1;
   do j=1 to 45;
      y0=10 + rannor(99);
      y1= y0 + 0.75*Trt + rannor(99);
      if (ranuni(99) < 0.3) then y1=.;
      output;
   end; end;
   drop j;
run;

proc print data=mono2(obs=10);
   var Trt Y0 Y1;
   title 'First 10 Obs in the Trial Data';
run;

proc mi data=Mono2 seed=14823 nimpute=10 out=outmi;
   class Trt;
   monotone reg;
   var Trt y0 y1;
run;

ods listing close;
proc reg data=outmi;
   model y1= Trt y0;
   by  _Imputation_;
   ods output parameterestimates=regparms;
run;

ods listing;
proc mianalyze parms=regparms;
   modeleffects Trt;
run;

/*----------------------------------------------------------------*/
/*--- Generate imputed data set for specified shift parameters ---*/
/*--- data= input data set                                     ---*/
/*--- smin= min shift parameter                                ---*/
/*--- smax= max shift parameter                                ---*/
/*--- sinc= increment of the shift parameter                   ---*/
/*--- out=  output imputed data set                            ---*/
/*----------------------------------------------------------------*/
%macro midata( data=, smin=, smax=, sinc=, out=);

data &out;
   set _null_;
run;

/*------------ # of shift values ------------*/
%let ncase= %sysevalf( (&smax-&smin)/&sinc, ceil );

/*------- Imputed data for each shift -------*/
%do jc=0 %to &ncase;
   %let sj= %sysevalf( &smin + &jc * &sinc);

   proc mi data=&data seed=14823 nimpute=10 out=outmi;
      class Trt;
      monotone reg;
      mnar adjust( y1 / shift=&sj  adjustobs=(Trt='1') );
      var Trt y0 y1;
   run;

   data outmi;
      set outmi;
      Shift= &sj;
   run;

   data &out;
      set &out outmi;
   run;

%end;
%mend midata;

ods listing close;
%midata( data=Mono2, smin=-2, smax=0, sinc=0.2, out=out1);

/*------- Reg tests on imputed data sets -------*/
/*------- for each shift parameter -------------*/
proc reg data=out1;
   model y1= Trt y0;
   by  Shift _Imputation_;
   ods output parameterestimates=regparms;
run;

/*------ Combine reg results -------*/
proc mianalyze parms=regparms;
   modeleffects Trt;
   by  Shift;
   ods output parameterestimates=miparm1;
run;

ods listing;
proc print label data=miparm1;
   var Shift Probt;
   title 'P-values for Shift Parameters';
   label Probt='Pr > |t|';
   format Probt 8.4;
run;

ods listing close;
%midata( data=Mono2, smin=-1.4, smax=-1.2, sinc=0.01, out=out2);

/*------- Reg tests on imputed data sets -------*/
/*------- for each shift parameter -------------*/
proc reg data=out2;
   model y1= Trt y0;
   by  Shift _Imputation_;
   ods output parameterestimates=regparms;
run;

/*------ Combine reg results -------*/
proc mianalyze parms=regparms;
   modeleffects Trt;
   by  Shift;
   ods output parameterestimates=miparm2;
run;

ods listing;
proc print label data=miparm2;
   var Shift Probt;
   title 'P-values for Shift Parameters';
   label Probt='Pr > |t|';
   format Probt 8.4;
run;