Uwe Siebert

Real World Health Care Data Analysis


Скачать книгу

_meancont;

      BY variable1 _strata_ _name_ _statn;

      RETAIN stddiff;

      IF UPCASE(_stat) = ‘MEAN’ THEN

      DO;

      stddiff = trt_1 - trt_0;

      END;

      ELSE IF UPCASE(_stat) = ‘STDDEV’ THEN

      DO;

      IF trt_1 ^= 0 THEN stddiff = stddiff / trt_1;

      ELSE stddiff = .;

      END;

      IF LAST._name_;

      KEEP variable1 _name_ stddiff _strata_; RUN;

      PROC SORT DATA = _mean;

      BY variable1 _strata_; RUN;

      PROC TRANSPOSE DATA=_mean (DROP=_type_ _freq_) OUT=_mean_t PREFIX=trt_;

      BY variable1 _strata_;

      ID _cohort; RUN;

      PROC SORT DATA = _mean_t;

      BY variable1 _strata_; RUN;

      DATA stddiff0_;

      SET _mean_t;

      trt_1 = FUZZ(trt_1);

      var1 = trt_1 * ( 1 - trt_1);

      IF var1 ^= 0 AND trt_0 NOT IN (0 1) THEN

      stddiff = (trt_1 - trt_0) / SQRT(var1);

      KEEP variable1 stddiff _strata_; RUN;

      PROC SORT DATA = _meanclass;

      BY variable1 _strata_;

      RUN;

      PROC TRANSPOSE DATA = _meanclass (DROP = _type_ _freq_) OUT =

      _meanclass_t PREFIX = trt_;

      BY variable1 _strata_;

      ID _cohort; RUN;

      PROC SORT DATA = _meanclass_t;

      BY variable1 _strata_ _name_; RUN;

      DATA stddiff2_ (RENAME = (_name_ = variable2));

      SET _meanclass_t;

      trt_1 = FUZZ(trt_1);

      var1 = trt_1 * ( 1 - trt_1);

      IF var1 ^= 0 AND trt_0 NOT IN (0 1) THEN

      stddiff = (trt_1 - trt_0) / SQRT(var1);

      KEEP variable1 _name_ stddiff _strata_; RUN;

      DATA _stddiff;

      SET _stddiff stddiff0_ (IN = in0) stddiff1_ (IN = in1) stddiff2_(IN = in2);

      IF in0 THEN

      DO;

      vartype2 = ‘ ‘;

      variable1 = UPCASE(variable1);

      vartype1 = ‘C’;

      END;

      IF in1 THEN

      DO;

      variable2 = UPCASE(variable2);

      _var = UPCASE(REVERSE(variable1));

      IF NOT(variable2 =: REVERSE(SUBSTR(_var, INDEX(_var, ‘_’) + 1)));

      vartype2 = ‘ ‘;

      variable1 = UPCASE(variable1);

      vartype1 = ‘C’;

      END;

      IF in2 THEN

      DO;

      variable2 = UPCASE(variable2);

      _var = UPCASE(REVERSE(variable1));

      IF NOT(variable2 =: REVERSE(SUBSTR(_var, INDEX(_var, ‘_’) + 1)));

      vartype2 = ‘C’;

      variable1 = UPCASE(variable1);

      vartype1 = ‘C’;

      END;

      KEEP variable1 variable2 stddiff _strata_ vartype1 vartype2; RUN;

      %endmac:

      %MEND _ps_stddiff_apmb;

      Program 4.9: Automatic Propensity Score Estimation Model

      *************************************************************************

      * Macro Name: PS_CALC_APMB *

      * Parameters: *

      * INDATA Name of the input dataset containing propensity scores *

      * OUTDATA Name of the output dataset [&indata] *

      * COHORT Name of variable containing the cohort/treatment variable*

      * TREATED A string with the value of &COHORT denoting treated *

      * patients

      * CONTVARS List of continuous covariates to include in this table *

      * CLASSVARS List of categorical covariates to include in this table *

      * PS Name of variable to contain the propensity scores *

      * CRIT The criteria to be used to consider an interaction term *

      * balanced *

      * MAXITER Maximum number of iterations allowed [800] *

      * NSTRATA Number of strata [5] *

      * IMBAL_STRATA_CRIT The criteria to be used to consider a strata *

      * balanced *

      * IMBAL_NSTRATA_CRIT Minimum number of imbalanced strata for a term *

      * to be considered imbalanced. *

      * ENTRY_NSTRATA_CRIT Minimum number of imbalanced strata for an *

      * interaction term to be considered for entry into the model. *

      * ALWAYS_INT Interaction term that are to always be included into the *

      * model *

      * DEBUG To reduce the amount of information written to the SAS log, *

      * this parameter is set to NO by default [NO] | YES. *

      ************************************************************************;

      %MACRO ps_calc_apmb (

      indata = ,

      outdata = ,

      cohort = _cohort,

      contvars = ,

      classvars = ,

      ps = ps,

      treated = _treated,

      n_mp_min = 100,

      maxiter = 800,

      imbal_strata_crit = 0.25,

      imbal_nstrata_crit = 2,

      entry_nstrata_crit = 2,

      nstrata = 5,

      debug = NO,

      always_int =

      );

      %PUT Now executing macro %UPCASE(&sysmacroname);

      %_ps_util;

      %LET _notes = %SYSFUNC(GETOPTION(NOTES));

      %LET _mprint = %SYSFUNC(GETOPTION(MPRINT));

      %LET _mlogic = %SYSFUNC(GETOPTION(MLOGIC));

      %LET _symbolgen = %SYSFUNC(GETOPTION(SYMBOLGEN));

      ODS HTML CLOSE;

      ODS LISTING CLOSE;

      %* Checking parameter specifications;

      %IF %BQUOTE(&indata) = %THEN

      %DO;