DATA Step, Macro, Functions and more

MACRO - Proc Genmod & Proc MIANALYZE

Reply
itk
N/A
Posts: 1

MACRO - Proc Genmod & Proc MIANALYZE

Hi,

I'm using MACRO for PROC GENMOD and PROC MIANALYZE.  I need to reformat the covb and the parminfo ODS tables for them to be used in the multiple imputation inference.  However, Log shows error, and I can't fix it.  Step 1 and 2 were PROC MI for missing data imputation, and here is a code.

* Step 3: Regression using imputed data sets;

%macro comb(m02,y,b,i);

* 1)Sort by imputation;

proc sort data=&m02;

    by _imputation_;

run;

* 2)Find number of imputations;

proc means data=&m02 noprint;

    var _imputation_;

    output out=maximp max=numimp;

run;

data _null_;

    set maximp;

    call symputx ("nimp",numimp);

run;

* 3)Find n of observations per imputation & n of dependent variable categories;

proc freq data=&m02;

    where &y ne .;

    tables &y / out=count;

    title1 "Frequency for &y";

run;

proc means data=count noprint;

    var count;

    output out=total sum=numobs n=numcat;

run;

data _null_;

    set total;

    call symputx ("nobs",numobs/&nimp);

    call symputx ("ncat",numcat);

    call symputx ("nint",numcat-1);

run;

* 4)Perform statistical analyses for each iteration;

proc sort data=&m02;

    by _Imputation_;

proc genmod data=&m02;

    class pon_id;

    by _imputation_;

    model &y=&b /d=P link=log covb;

    repeated subject=pon_id/corrw type=exch ecovb printmle;

    ods output GEEEmpPEst=gmparms&i

               GEERCov=gmcovb&i

               ParmInfo=pinfo&i;

run;

* 5)Obtain the n of independent variables;

proc means data=pinfo&i noprint;

    var _imputation_;

    output out=sumvar sum=numvar;

    where _imputation_=1;

run;

data _null_;

    set sumvar;

    call symputx ("nvar",numvar);

    call symputx ("ndf",(&nobs-&nint-numvar));

run;

* 6)Begin the FIX macro;

%macro fix(numcat,numvar);

* 7)Reformat the covb dataset;

data gmcovb&i;

    set gmcovb&i;

        %do j=1 %to &numvar;

        %let newnum=%eval(&j+&numcat-1);

        rename Prm&j=Prm&newnum;

        if RowName="Prm&j" then do;

           Rowname="Prm&newnum";

        end;

        %end;

        %do j=1 %to &nint;

        rename Intercept&j=Prm&j;

        if RowName="Intercept&j" then do;

           Rowname="Prm&j";

        end;

        %end;

run;

* 8)Reformat the parminfo dataset;

data Pinfo&i;

    set Pinfo&i;

        %do j=1 %to %eval(&numvar-1);

        %let newnum=%eval(&j+&numcat-1);

        if Parameter="Prm&j" then do;

           Parameter="Prm&newnum";

        end;

        else

        %end;

        %let newnum=%eval(&j+&numcat-1);

        if Parameter="Prm&j" then do;

           Parameter="Prm&newnum";

        end;

run;

data int;

    length Parameter $30. Effect $30.;

        %do k=1 %to &nimp;

        %do j=1 %to &nint;

            _Imputation_=&k;

            Parameter="Prm&j";

            Effect="Intercept&j";

            output;

        %end;

        %end;

run;

data Pinfo&i;

    set int Pinfo&i;

run;

%mend fix;

%fix(&ncat,&nvar);

* 9)Multiple imputation inference;

%macro listint(k);

    %do j=1 %to &k;

        Intercept&j

    %end;

%mend listint;

proc mianalyze parms=gmparms&i covb=gmcovb&i parminfo=pinfo&i edf=&ndf;

    modeleffects %listint(&nint) &b ;

    ods output ParameterEstimates=combined&i VarianceInfo=var&i;

run;

* 10)Calculate RR;

data combined&i;

    set combined&i;

    se=stderr;

    RR=put(exp(estimate),8.2);

    RRlowbound=put(exp(lclmean),8.2);

    RRupbound=put(exp(uclmean),8.2);

    minimpRR=put(exp(min),8.2);

    maximpRR=put(exp(max),8.2);

run;

%mend comb;

options mprint;

%comb(m02,y,b_1,1)

I have error messages as follow:

MPRINT(COMB):   * 9)Multiple imputation inference;

MPRINT(COMB):   proc mianalyze parms=gmparms1 covb=gmcovb1 parminfo=pinfo1 edf=144;

MPRINT(COMB):   modeleffects

MPRINT(LISTINT):   Intercept1

MPRINT(COMB):   ln_UBAFF_1 age bmi race_d smoking_d;

MPRINT(COMB):   ods output ParameterEstimates=combined1 VarianceInfo=var1;

MPRINT(COMB):   run;

ERROR: The parameter Prm1 in the PARMINFO= data set is not in the COVB= data set.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: Output 'VarianceInfo' was not created.  Make sure that the output object name, label, or

         path is spelled correctly.  Also, verify that the appropriate procedure options are used

         to produce the requested output object.  For example, verify that the NOPRINT option is

         not used.

WARNING: Output 'ParameterEstimates' was not created.  Make sure that the output object name,

         label, or path is spelled correctly.  Also, verify that the appropriate procedure

         options are used to produce the requested output object.  For example, verify that the

         NOPRINT option is not used.

MPRINT(COMB):   * 10)Calculate RR;

MPRINT(COMB):   data combined1;

MPRINT(COMB):   set combined1;

ERROR: File WORK.COMBINED1.DATA does not exist.

MPRINT(COMB):   se=stderr;

MPRINT(COMB):   RR=put(exp(estimate),8.2);

MPRINT(COMB):   RRlowbound=put(exp(lclmean),8.2);

MPRINT(COMB):   RRupbound=put(exp(uclmean),8.2);

MPRINT(COMB):   minimpRR=put(exp(min),8.2);

MPRINT(COMB):   maximpRR=put(exp(max),8.2);

MPRINT(COMB):   run;

It seems like I have this message because reformat at step 7 and 8 did not work properly.  I wonder if anyone can suggest what should I do to solve this problem.

Thanks!

Ask a Question
Discussion stats
  • 0 replies
  • 390 views
  • 0 likes
  • 1 in conversation