Uwe Siebert

Real World Health Care Data Analysis


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

specified!

       Execution of this macro will be stopped!;

      %LET _errfound = 1;

      %GOTO endmac;

      %END;

      %IF %BQUOTE(&contvars) = AND %BQUOTE(&classvars) = %THEN

      %DO;

      %PUT %STR(ER)ROR: Neither CLASSVARS nor CONTVARS have been

       specified! Execution of this macro will be stopped!;

      %LET _errfound = 1;

      %GOTO endmac;

      %END;

      DATA _NULL_;

      CALL SYMPUT(‘_indata’, SCAN(“&indata”, 1, ‘ ()’));

      RUN;

      %IF %BQUOTE(&outdata) = %THEN

      %LET outdata = &indata;

      %IF %SYSFUNC(EXIST(&_indata)) = 0 %THEN

      %DO;

      %LET _errfound = 1;

      %PUT %STR(ER)ROR: Input dataset does not exist! Execution of

       this macro will be stopped!;

      %GOTO endmac;

      %END;

      DATA _indata;

      SET &indata;

      RUN;

      %IF %BQUOTE(&treated) = %THEN

      %DO;

      %PUT %STR(ER)ROR: Parameter TREATED has been specified as

       blank! Execution of this macro will be stopped!;

      %LET _errfound = 1;

      %GOTO endmac;

      %END;

      %ELSE

      %DO;

      DATA _NULL_;

      IF SUBSTR(SYMGET(“treated”), 1, 1) ^= ‘”’ AND

      SUBSTR(SYMGET(“treated”), 1, 1) ^= “’” THEN

      CALL SYMPUT(“_treatedvar”, “1”);

      ELSE CALL SYMPUT(“_treatedvar”, “0”);

      RUN;

      %END;

      PROC CONTENTS DATA = &indata OUT = _contents_psm NOPRINT;

      RUN;

      %LET _ps_exist = 0;

      %LET _cohort_exist = 0;

      %LET _treated_exist = 0;

      %LET __cohort_exist = 0;

      DATA _NULL_;

      SET _contents_psm;

      IF UPCASE(name) = UPCASE(“&cohort”) THEN

      DO;

      CALL SYMPUT(‘_cohort_exist’, ‘1’);

      CALL SYMPUT(‘_coh_tp’, COMPRESS(PUT(type, BEST.)));

      CALL SYMPUT(‘_coh_fmt’, COMPRESS(format));

      CALL SYMPUT(‘_coh_lab’, TRIM(LEFT(label)));

      END;

      ELSE IF UPCASE(name) = UPCASE(“_cohort”) THEN

      CALL SYMPUT(‘__cohort_exist’, ‘1’);

      ELSE IF UPCASE(name) = UPCASE(“&ps”) THEN

      CALL SYMPUT(‘_ps_exist’, ‘1’);

      %IF &_treatedvar = 1 %THEN

      %DO;

      ELSE IF UPCASE(name) = UPCASE(“&treated”) THEN

      CALL SYMPUT(‘_treated_exist’, ‘1’);

      %END;

      RUN;

      %IF &_ps_exist = 1 %THEN

      %DO;

      %PUT %STR(WAR)NING: PS variable &ps already exists in dataset

       &indata! This variable will be overwritten!;

      DATA _indata;

      SET _indata (DROP = &ps);

      RUN;

      %END;

      %IF &_cohort_exist = 0 %THEN

      %DO;

      %LET _errfound = 1;

      %PUT %STR(ER)ROR: Cohort variable &cohort not found in dataset

      &indata! Execution of this macro will be stopped!;

      %GOTO endmac;

      %END;

      %IF &_treated_exist = 0 AND &_treatedvar = 1 %THEN

      %LET _treatedvar = 0;

      %IF &_treatedvar = 1 %THEN

      %DO;

      PROC SQL NOPRINT;

      SELECT DISTINCT &treated INTO: _treated FROM _indata;

      QUIT;

      %LET treated = “&_treated”;

      %IF &sqlobs > 1 %THEN

      %DO;

      %PUT %STR(ER)ROR: More than one value found for

       variable &treated! Execution of this macro

       will be stopped!;

      %GOTO endmac;

      %END;

      %END;

      PROC SQL NOPRINT;

      CREATE TABLE _NULL_ AS SELECT DISTINCT &cohort FROM &indata WHERE

      &cohort = &treated;

      QUIT;

      %LET _fnd_treated = &sqlobs;

      %IF &_fnd_treated = 0 %THEN

      %DO;

      %LET _errfound = 1;

      %PUT %STR(ER)ROR: Value &treated not found for variable

       &cohort! Execution of this macro will be stopped!;

      %GOTO endmac;

      %END;

      PROC SQL NOPRINT;

      CREATE TABLE _cohort_psm AS SELECT DISTINCT &cohort FROM &indata WHERE

       NOT MISSING(&cohort);

      QUIT;

      %LET _n_cohort = &sqlobs;

      %IF &_n_cohort > 2 %THEN

      %DO;

      %LET _errfound = 1;

      %PUT %STR(ER)ROR: More than 2 values for variable &cohort

       found! Execution of this macro will be stopped!;

      %GOTO endmac;

      %END;

      %ELSE %IF &_n_cohort < 2 %THEN

      %DO;

      %LET _errfound = 1;

      %PUT %STR(ER)ROR: Less than 2 values for variable &cohort

       found! Execution of this macro will be stopped!;

      %GOTO endmac;

      %END;

      %LET _errfound = 0;

      %* Creating a derived variable _COHORT with value 1 for treated and 0 for

       control;

      DATA