**SAS Macros for the Consumer Expenditure Surveys 2017**

**Introduction**

The Consumer Expenditure (CE) Surveys has a complex sample design and the Balanced Repeated Replication (BRR) method of variance estimation is used to calculate variances.  Also beginning with year 2004 multiply imputed income data is available for analysis.  

Previous SAS versions did not have built-in procedures to compute survey variances using the BRR method of variance estimation or to perform analysis using multiply imputed data, therefore a SAS macro program was written in order to help with the SAS programming and to encourage the use of weights in data analysis. 

Now SAS have built-in procedures to perform analysis for multiply imputed data and to compute survey variances using the BRR method.  The new macro program use the new SAS procedures PROC SURVEYMEANS, PROC SURVEYREG, PROC SURVEYLOGISTIC, and PROC MIANALIZE.  

This document explains how to use the new macros MEAN_VARIANCE, PROC_REG, and PROC_LOGISTIC to compute means, confidence intervals for the mean, standard errors, total variance and to perform regression and logistic analysis for weighted and un-weighted CE non-imputed and multiply imputed data.  The macro programs perform calculations for expenditure, income and demographic variables from the “FMLY”, “MEMB” and “EXPN” files. 

**Argument definitions for the macro MEAN_VARIANCE**

*DSN*: Dataset name.

*ANALVARS*: Analysis variables 

*IMPUTED_VARS*: Imputed variables. Ex. INTEARNM[footnoteRef:1] [1:  When using multiply imputed data all imputed variables must be read.  Example: if INTEARNM is used then the dataset must include the variables INTEARN1, INTEARN2, INTEARN3, INTEARN4, INTEARN5, and INTEARNM.] 

*COMPARE_GPS*: Compare means of by variable groups (default = no).

**Argument definitions for the macros PROC_REG and PROC_LOGISTIC**

*DSN*: Dataset name.

*DEP_VARS*: Dependent (response) variable for your model.  If the model is run for different dependent variables with the same set of independent variables, then more than one dependent variable name can be enter separated by a space.

*IND_VARS*: Independent variables for your model.  (Include all continuous variables in the model separated by a space).

*IMPUTED_VARS*: These are also independent variables for your model.

**Optional arguments for the PROC_LOGISTIC macro**

*LINK*: Specify the link function that links the response probabilities to the linear predictors.  (default = LOGIT, option = GLOGIT).

*SORT_ORDER*: To change the default sorting order of the response variable. (options = DATA, FORMATTED, FREQ, INTERNAL)

*CLASSVARS*: Independent classification variables and sorting order options to be used in the CLASS statement of the PROC_LOGISTIC macro. 

**COMPAREn arguments[footnoteRef:2] for PROC_REG and PROC_LOGISTIC macros** [2:  If comparing parameter estimates for multiply imputed data then the compare argument should include the variable name without the final M. Example: if INTEARNM is used then the compare arguments should use INTEARN. ] 

The “*COMPAREn*” arguments where n = 1 to 9 perform comparisons of parameter estimates by calling the statements TEST, MTEST, or CONTRAST.

**PROC_REG macro**

For non-imputed un-weighted data the macro calls the **PROC REG** statements:

a)  “**TEST**” which tests hypotheses about the parameters estimated in the MODEL statement.    	

    <label:> **TEST** equation  

b)  “**MTEST**” where each ***equation*** is a linear function composed of coefficients and variable names. The ***label*** is optional. The MTEST statement is used to test hypotheses in multivariate regression models where there are several dependent variables fit to the same regressors. If no equations or options are specified, the MTEST statement tests the hypothesis that all estimated parameters except the intercept are zero.  <*label:*> **MTEST***equation*

For non-imputed weighted data the macro calls the **PROC SURVEYREG** statements:

a)  “**TEST**” which enables you to perform F tests for model effects that test Type I, II, or Type III hypotheses.  Chisq option requests chi-square tests.  <*label:*> **TEST***equation / chisq*

b) “**CONTRAST**” which provides custom hypothesis tests for linear combinations of the regression parameters.  **CONTRAST** ’label’ effect values

**PROC_LOGISTIC macro**

For non-imputed data the macro calls the **PROC LOGISTIC**and**PROC SURVEYLOGISTIC** statements:

a) With LINK = LOGIT: “**TEST**” which tests linear hypotheses about the regression coefficients.  <label:> **TEST** equation 

b)  With LINK = GLOGIT: “**CONTRAST**” which provides a mechanism for obtaining customized hypothesis tests.  **CONTRAST** ’label’ row-description

**PROC_REG and PROC_LOGISTIC macros**

For imputed data the macro calls the **PROC MIANALYZE** statement “**TEST**” which tests linear hypotheses about the parameters . An test is used to jointly test the null hypotheses () specified in a single TEST statement in which the MULT option is specified.  *<label:>***TEST***equation**/ mult*

**Optional arguments for all macros**

*FORMAT:*Formats for any of the variables in the dataset.  Do not use “,” or “( )” in your formats.

*USE_WEIGHTS[footnoteRef:3]*: Yes if weighted data is used, no if un-weighted data is used (default  = NO) [3:  The use of weights in the Consumer Expenditure Surveys is not appropriate at the member level. ] 

*BYVARS*: By variables if analysis is needed by groups.

*CL*: Confidence level for confidence intervals for the mean (default = 95).

*DF[footnoteRef:4]*: Degrees of freedom definition to be used for multiply imputed data (default = Rubin99, option = Rubin87). [4:  For details on degrees of freedom definitions see John Barnard; Donald B. Rubin, “Small-Sample Degrees of Freedom with Multiple Imputation” Biometrika, Vol. 86, No. 4 (Dec., 1999), pp. 948-955.] 

*TITLEn*: Title n for the output: where n = 1 to 5.

*XOUTPUT*: Extra output with results of the preliminary 5 imputations.

*REP_WT*: Number of replicate weights (Default = 44, Option = 20)

*IMPUTATIONS*: Number of imputations (Default = 5)

· Arguments REP_WT and IMPUTATIONS.  

· The argument REP_WT is the number of replicate weights (default = 44, option = 20). This gives the ability to change the number of replicates from 44 to 20 for the use of the macros with data from years with only 20 replicate weights.  [20 replicate weights from 1984 QTR1 to 1986 QTR2 and 44 replicate weights from 1986 QTR2 to PRESENT] 

· The argument IMPUTATIONS is the number of imputations (default = 5). This variable give the ability to change the number of imputations in the macro calls. 

**How to use the macros:**

1. Include the macro program (called “CE_MACROS_2017.SAS” for instruction purposes) in your program using the %INCLUDE command. For example, if your program is stored in the D:\drive under a folder called, “PROGRAMS,” then the instruction is:  

%INCLUDE "D:\PROGRAMS\CE_MACROS_2017.SAS";

2. Read your data as usual.  The macros will NOT annualize the expenditures.  To obtain annual results for the Interview survey multiply expenditures by four, for the Diary survey multiply expenditures by 52. 

3. For weighted data include the variable FINLWT21 and the replicate weight variables WTREP01 – WTREP44 in your dataset. **Important:**These variables should not be renamed.  (The macros will NOT annualize the weights.) 

4. **Important:** Arguments in all macro calls must be separated by commas. 

    %**MEAN_VARIANCE**(DSN = CEDATA, 

   FORMAT = BLS_URBN $URBN.,

	    USE_WEIGHTS = Yes,

       ANALVARS = TOTEXPPQ AGE_REF, 

   IMPUTED_VARS = FINCBTXM FSALARYM,

             CL = ,

         BYVARS = BLS_URBN

     );

5. Dependent and Independent variables for the regression procedure must be numeric variables in the data set being analyzed.

6. Enter values for the arguments 

· DSN and ANALVARS or IMPUTED_VARS (or both), and any other optional arguments in the MEAN_VARIANCE macro call.  

· DSN, DEP_VARS and IND_VARS or IMPUTED_VARS (or both), and any other optional arguments in the PROC_REG or PROC_LOGISTIC macro call.

**Using the optional arguments in the macro calls**

1. If the user has defined formats for any variables in the dataset then include the argument “FORMAT = variable(s) <format>” in the macro calls.     

2. If weighted analysis is desired then include the argument “USE_WEIGHTS = YES” in the macro calls (Default is “USE_WEIGHTS = NO”).

3. If “BY” variables are used in the analysis then include the argument “BYVARS = byvariable(s)” in the macro calls and the macros will sort the dataset. 

4. No intervention from the user is necessary to get 95% confidence intervals for the means.  Different confidence level can be requested by adding the argument “CL = number” in the MEAN_VARIANCE macro call (Default is “CL = 95”). 

5. For degrees of freedom of multiply imputed data calculated using the Rubin87 definition add the argument “DF = Rubin87” in the macro calls (Default is “DF = Rubin99”). 

6. The user can add up to five titles to the output by adding the arguments “TITLE1 =”, “TITLE2 =”, “TITLE3 =”, “TITLE4 =”, and “TITLE5 =” in the macro calls.

7. To see the output for the 5 individual imputations add the argument “XOUTPUT = YES” in the macro calls (Default is “XOUTPUT = NO”). 

8. If comparison of the parameter estimates is desired for regression or logistic procedures then the user can add the up to 9 arguments to request those comparisons to the PROC_REG and PROC_LOGISTIC macro calls: 

PROC_REG

For un-weighted non-imputed data the following arguments can be added to the call.

“COMPAREn = < label**:** >**TEST***equation*” (n = 1 to 9).  

“COMPAREn = < label**:** >**MTEST***equation*” (n = 1 to 9).  

For weighted non-imputed data the following arguments can be add to the call.

“COMPAREn = < label**:** >**TEST***equation **<** /chisq **>***” (n = 1 to 9).  

“COMPAREn = **CONTRAST** ’label’ effect values” (n = 1 to 9).  

PROC_LOGISTIC

For weighted and un-weighted non-imputed data the following arguments can be added to the call.

With the LINK = LOGIT option: “**TEST**” statement.

“COMPAREn = < label**:** >**TEST***equation*” (n = 1 to 9).  

With the LINK = GLOGIT option: “**CONTRAST**” statement.

 “COMPAREn = **CONTRAST** ’label’ row-description” (n = 1 to 9).  

PROC_REG and PROC_LOGISTIC

For weighted and un-weighted imputed data the following arguments can be added to the call.

“COMPAREn = < label**:** >**TEST***equation **<** /mult **>***” (n = 1 to 9).  

For these arguments the label is used to identify the output.  Only one equation per “COMPAREn” argument should be entered.  

See SAS manual for details on the TEST, MTEST, and CONTRAST statements options and definitions for PROC REG, PROC SURVEYREG, PROC LOGISTIC, PROC SURVEYLOGISTIC, and PROC MIANALYZE.    

**Changing the defaults**

Example: 

Change defaults for USE_WEIGHTS and CL.

     %**MEAN_VARIANCE**(DSN = CEDATA, 

	     USE_WEIGHTS = Yes,

    IMPUTED_VARS = FSALARYM,

              CL = 90

     );

**Optional Arguments for the PROC_LOGISTIC macro**

**SORT ORDER**

For PROC LOGISTIC the response variable can be character or numeric.  Values of this variable are sorted by the ORDER= option in the PROC LOGISTIC statement.  There are two types of logistic regressions, the first when the dependent variable has two levels (0, 1) and the second when the dependent variable has more than two levels (1, 2, 3, 4).  The PROC_LOGISTIC macro will read the dependent variables and determine what kind of logistic regression to run.  No intervention from the user is necessary unless a different sorting order of the levels of the dependent variable is desired.  If different sorting order for the dependent variables is desired, enter values for SORT_ORDER.  SORT_ORDER specifies the sort order for the levels of the dependent variable.  

**Changing the default sorting order of the dependent variable**

The default sort order values for the dependent variable in the PROC_LOGISTIC macro are: 

· For a two level dependent variable (0, 1) the LOGISTIC procedure is modeling the probability that the dependent variable is equal to 1, that is, the default sorting order is DESCENDING**.**

If modeling the probability that the dependent variable equal to 0 is desired set SORT_ORDER = INTERNAL in the macro call. 

· For dependent variables with more than two levels for the LOGISTIC procedure the program is setup to sort the dependent variable by its ascending numeric order, that is SORT_ORDER = INTERNAL. 

If sorting the dependent variable by its formatted alphabetical value is desired then set SORT_ORDER = FORMATTED in the macro call. 

See SAS manuals for details on the sorting options definitions.

**CLASSVARS**

For PROC LOGISTIC the independent variables can be either continuous or classification variables.  Classification variables can be character or numeric, and they must be declared in the CLASS statement.  An independent variable that is not declared in the CLASS statement is assumed to be continuous.  No intervention from the user is necessary unless the user wants independent classification variables in the model.  If using independent classification variables enter values for CLASSVARS.

**Adding independent classification variables and changing its default sorting order**

If there are independent classification variables in the model, then a statement with the names of the variables and the sorting order has to be included in the macro call.  To define independent classification variables set CLASSVARS = X1 X2 in the macro call.  These are the values for the CLASS statement in the PROC LOGISTIC procedure. 

If no sorting order is specified, then the default ORDER=FORMATTED is applied.  For numeric variables for which no format is supplied the levels are ordered by their internal (numeric) value.  To change the sorting order of the classification variables include the sorting options in the CLASS statement instruction, set CLASSVARS = X1 (ORDER= FREQ) X2 (ORDER = INTERNAL) / DESCENDING.  

See SAS manuals for sorting order definitions for the CLASS statement in the PROC LOGISTIC procedure.

**References:**

· SAS online documentation

**Sample Program using 4 quarters of data**

OPTIONS PAGENO=**1** NOCENTER;

/* INCLUDE THE MACRO IN YOUR PROGRAM */

%INCLUDE "D:\Programs\CE_macros_2017.sas";

/* INSERT THE LIBRARY NAME WHERE THE DATA IS STORE */

libname IN "C:\CEQData\";		

/* DEFINE FORMATS */

**PROC****FORMAT**;

VALUE $URBN

       '1' = 'Urban'

 	 '2' = 'Rural'

	 ;

**RUN**;

/* VARIABLES TO READ FROM THE FAMILY FILE */

%LET FMLIVARS = NEWID WTREP01-WTREP44 FINLWT21 

                FINCBTAX FINCBTX1-FINCBTX5 FINCBTXM 

	          TOTEXPPQ TOTEXPCQ BLS_URBN

                ;

**DATA** FMLY;

SET IN.FMLI151X (KEEP=&FMLIVARS.)

    IN.FMLI152 (KEEP=&FMLIVARS.)

    IN.FMLI153 (KEEP=&FMLIVARS.)

    IN.FMLI154 (KEEP=&FMLIVARS.)

    ;

/* CREATE ARRAY OF WEIGHTS */

      ARRAY A(**45**) WTREP01-WTREP44 FINLWT21;

/* ANNUALIZE THE WEIGHTS */

      DO I=**1** TO **45**;

/* CONVERT MISSING WEIGHTS TO ZERO */

        IF A(I)< **0** THEN A(I)=**0**;

/* CREATE ANNUAL WEIGHTS FOR CORRECT US POPULATION DIVIDE BY NUMBER OF QUARTERS USED */

        A(I)=A(I)/**4**;

        DROP I; 

       END;

/* CREATE NEW TOTAL EXPENDITURE VARIABLE */

TOTALEXP = SUM(**0**,TOTEXPPQ,TOTEXPCQ);

/* ANNUALIZE THE EXPENDITURES */

ANNEXP = **4***TOTALEXP;

**RUN**;

/* VARIABLES TO READ FROM THE MEMBER FILE */

%LET MEMIVARS = NEWID SALARYX1-SALARYX5 SALARYXM;

**DATA** MEMB;

SET IN.MEMI151X (KEEP=&MEMIVARS.)

    IN.MEMI152 (KEEP=&MEMIVARS.)

    IN.MEMI153 (KEEP=&MEMIVARS.)

    IN.MEMI154 (KEEP=&MEMIVARS.)

    ;

IF SALARYXM>**0**;

**RUN**;

/******************************************************************/

/* MACRO MEAN_VARIANCE                                            */

/******************************************************************/

/******************************************************************/

/* DSN:  		 DATASET NAME						*/

/* FORMAT:         FORMATS IF ANY					      */

/* USE_WEIGHTS:    YES OR NO (DEFAULT = NO)			      */

/* BYVARS:  	 BY VARIABLES IF ANY					*/

/* ANALVARS: 	 ANALYSIS VARIABLE NAMES				*/

/* IMPUTED_VARS:   IMPUTED VARIABLE NAMES					*/

/* COMPARE_GPS:	 YES OR NO (DEFAULT = NO)				*/

/* CL:  		 CONFIDENCE LEVEL (DEFAULT IS 95)		      */

/* DF:  		 DEGREES OF FREEDOM DEFINITION                  */

/*					(DEFAULT IS RUBIN99)		      */

/*                            (OPTION IS RUBIN87)                 */

/* TITLE1:  	 TITLE 1 FOR OUTPUT				      */

/* TITLE2:  	 TITLE 2 FOR OUTPUT				      */

/* TITLE3:  	 TITLE 3 FOR OUTPUT				      */

/* TITLE4:  	 TITLE 4 FOR OUTPUT				      */

/* TITLE5:  	 TITLE 5 FOR OUTPUT				      */

/* XOUTPUT         PRINT EXTRA OUTPUT(DEFAULT IS NO)              */

/* REP_WT:  	 NUMBER OF REPLICATE WEIGHTS                    */

/*					(DEFAULT IS 44)		            */

/*                            (OPTION IS 20)                      */

/* IMPUTATIONS:    NUMBER OF IMPUTATIONS (DEFAULT = 5)		*/

/******************************************************************/

/******************************************************************/

/* CALCULATE MEAN, VARIANCE AND TOTAL VARIANCE                    */

/* FOR WEIGHTED OR UNWEIGHTED DATA						*/

/******************************************************************/

**%MEAN_VARIANCE**(DSN = , 

	      FORMAT = , 

	 USE_WEIGHTS = ,

	      BYVARS = , 

	    ANALVARS = , 

	IMPUTED_VARS = ,

	 COMPARE_GPS = ,

                CL = ,

                DF = , 

	      TITLE1 = ,

	      TITLE2 = ,

	      TITLE3 = ,

	      TITLE4 = ,

	      TITLE5 = ,

  	     XOUTPUT = ,

	      REP_WT = ,

 IMPUTATIONS = );

Calculate weighted means and standard errors for the variables ANNEXP and FINCBTAX and weighted means, standard errors, and total variance for the variable FINCBTXM from the FAMILY file, by degree of urbanization and 99% confidence intervals for the means.  Compare means of all variables by variable group BLS_URBN.

/* MACRO CALLS */

%***MEAN_VARIANCE***(DSN = FMLY, 

  	      FORMAT = BLS_URBN $URBN.,

       USE_WEIGHTS = YES,

	      BYVARS = BLS_URBN, 

	    ANALVARS = ANNEXP FINCBTAX, 

      IMPUTED_VARS = FINCBTXM,

	 COMPARE_GPS = YES,

                CL = **99**, 

	      TITLE1 = COMPUTING MEANS AND VARIANCES,

	      TITLE2 = VARIABLES FROM THE FAMILY FILE 

); 

Calculate un-weighted means, standard errors, and total variance for the variable SALARYXM from the MEMBER file with 95% confidence intervals for the means. 

Weights in the Consumer Expenditure Survey show how many consumer units (CU) in the population a sampled CU represents; therefore, analysis at the MEMBER level should be un-weighted.   

/* MACRO CALL FOR MEMBER FILE VARIABLES */

%***MEAN_VARIANCE***(DSN = MEMB, 

  	      FORMAT = , 

       USE_WEIGHTS = NO,

	      BYVARS = , 

	    ANALVARS = , 

      IMPUTED_VARS = SALARYXM,

                CL = **95**, 

	      TITLE1 = COMPUTING MEANS AND VARIANCES,

	      TITLE2 = VARIABLES FROM THE MEMBER FILE,

	      TITLE3 = SALARY RECIPIENTS ONLY,

	     XOUTPUT = ); 

**OLS Regression using PROC REG**

/**********************************************************/

/* MACRO PROC_REG                                         */

/**********************************************************/

/**********************************************************/

/* DSN:          DATASET NAME                             */

/* FORMAT:       FORMATS IF ANY				    */

/* USE_WEIGHTS:  YES OR NO (DEFAULT = NO)			    */

/* BYVARS:       BY VARIABLES IF ANY			    */

/* DEP_VARS:     DEPENDENT VARIABLE FOR YOUR MODEL        */

/* IND_VARS:     INDEPENDENT VARIABLES FOR YOUR MODEL     */

/* IMPUTED_VARS: IMPUTED VARIABLES FOR YOUR MODEL         */

/* CL:  	     CONFIDENCE LEVEL (DEFAULT IS 95)	    */

/* DF:  		 DEGREES OF FREEDOM DEFINITION          */

/*					(DEFAULT IS RUBIN99)	    */

/*                            (OPTION IS RUBIN87)         */

/* TITLE1:       TITLE 1 FOR OUTPUT				    */

/* TITLE2:       TITLE 2 FOR OUTPUT				    */

/* TITLE3:       TITLE 3 FOR OUTPUT				    */

/* TITLE4:       TITLE 4 FOR OUTPUT				    */

/* TITLE5:       TITLE 5 FOR OUTPUT				    */

/* XOUTPUT       PRINT EXTRA OUTPUT(DEFAULT IS NO)        */

/* REP_WT:       NUMBER OF REPLICATE WEIGHTS              */

/*			(DEFAULT IS 44)		      	    */

/*                (OPTION IS 20)            		    */

/* IMPUTATIONS:  NUMBER OF IMPUTATIONS (DEFAULT = 5)	    */

/*									    */

/* COMPARE MODEL PARAMETER ESTIMATES 		          */

/* 	FOR NON IMPUTED DATA				  	    */

/*      WEIGHTS = NO  			 			    */

/*		 PROC REG: TEST OR MTEST STATEMENTS 	    */

/*      WEIGHTS = YES  			 			    */

/*		 PROC SURVEYREG: TEST OR CONTRAST STATEMENTS  */

/*									    */

/* 	FOR IMPUTED DATA						    */

/*		WEIGHTED AND UNWEIGHTED 			    */

/*			PROC MIANALIZE: TEST STATEMENT	    */

/*									    */

/* COMPARE1:                      				    */

/* COMPARE2:                      				    */

/* COMPARE3:                      				    */

/* COMPARE4:                      				    */

/* COMPARE5:                      				    */

/* COMPARE6:                      				    */

/* COMPARE7:                      				    */

/* COMPARE8:                      				    */

/* COMPARE9:     							    */

/**********************************************************/

**%PROC_REG**(DSN = , 

 	 FORMAT = , 

  USE_WEIGHTS = ,

       BYVARS = ,

     DEP_VARS = , 

     IND_VARS = , 

 IMPUTED_VARS = ,

           CL = ,

           DF = , 

       TITLE1 = ,

       TITLE2 = ,

       TITLE3 = ,

       TITLE4 = ,

       TITLE5 = ,

      XOUTPUT = ,

       REP_WT = ,

  IMPUTATIONS = ,

     COMPARE1 = ,

     COMPARE2 = ,

     COMPARE3 = ,

     COMPARE4 = ,

     COMPARE5 = ,

     COMPARE6 = ,

     COMPARE7 = ,

     COMPARE8 = ,

     COMPARE9 = );

The following examples for the PROC_REG macro can all be modified by adding variables to the BYVARS argument.  The results will be presented by the levels of those variables. 

Also more than one dependent variable maybe included in the DEP_VARS argument.  This will result on analysis for models with different dependent variables with the same independent variables.  

For the “COMPAREn” arguments only one equation can be used per argument.  For example: “COMPARE1 = aplus: **TEST** a1 + a2 = 1”.  

**Example 1:**

**Un-weighted non-imputed data**

There are two independent variables Y1 and Y2; and two dependent variables X1 and X2 for the regression.  Therefore there are two models, X1 = Y1 + Y2 and X2 = Y1 + Y2.  The program will use un-weighted data and compare the parameter coefficients of Y1 and Y2.  Use TEST or MTEST statements for un-weighted non-imputed data to compare the parameter estimates.

%***PROC_REG***(DSN = ALL, 

  USE_WEIGHTS = NO,

     DEP_VARS = X1 X2, 

     IND_VARS = Y1 Y2,

     COMPARE1 = TEST_Y1_Y2: **TEST** Y1 = Y2,

     COMPARE2 = MTEST_Y1_Y2: **MTEST** Y1 - Y2);

**Example 2:**

**Weighted non-imputed data**

There are two independent variables Y1 and Y2; and one dependent variable X for the regression.  Therefore the model is X = Y1 + Y2.  The program will use weighted data and compare the parameter coefficients Y1 and Y2.  Use TEST or CONTRAST statements for weighted non-imputed data to compare the parameter estimates.  Use the CHISQ option for the TEST statement.

%***PROC_REG***(DSN = ALL, 

  USE_WEIGHTS = yes,

     DEP_VARS = X, 

     IND_VARS = Y1 Y2,

     COMPARE1 = TEST_Y1_Y2: **TEST** Y1 Y2/CHISQ,

     COMPARE2 = **CONTRAST** 'Y1_Y2' Y1 **1** Y2 -**1**);

**Example 3:**

**Un-weighted multiply imputed data**

There are four independent variables Y1, Y2, WM, and ZM and one dependent variable X for the regression.  Therefore the model is, X = Y1 + Y2 + WM + ZM. The program will use un-weighted data and compare the parameter coefficients of Y1 and Y2 and of W and Z.  Use TEST statement for un-weighted imputed data to compare the parameter estimates with the MULT option.

%***PROC_REG***(DSN = ALL, 

  USE_WEIGHTS = NO,

     DEP_VARS = X, 

     IND_VARS = Y1 Y2, 

 IMPUTED_VARS = WM ZM,

     COMPARE1 = TEST_Y1_Y2: **TEST** Y1 = Y2/MULT,

     COMPARE2 = TEST_W_Z: **TEST** W = Z/MULT

);

**Example 4:**

**Weighted multiply imputed data**

There are three independent variables Y1, WM, and ZM and one dependent variable X for the regression.  Therefore the model is X = Y1 + WM + ZM. The program will use weighted data and compare the parameter coefficients of Y1 and Y2 and of W and Z.  Use TEST statement for weighted imputed data to compare the parameter estimates with the MULT option.

%**PROC_REG**(DSN = ALL, 

  USE_WEIGHTS = Yes,

EP_VARS = X, 

     IND_VARS = Y1, 

 IMPUTED_VARS = WM ZM,

     COMPARE1 = TEST_Y1_Y2: **TEST** Y1 = Y2/MULT,

     COMPARE2 = TEST_W_Z: **TEST** W = Z/MULT

);

**Logistic Regression using PROC LOGISTIC**

/*********************************************************************/

/*********************************************************************/

/* MACRO PROC_LOGISTIC                                               */

/*********************************************************************/

/*********************************************************************/

/* DSN:          DATASET NAME                                        */

/* FORMAT:       FORMATS IF ANY				               */

/* USE_WEIGHTS:  YES OR NO (DEFAULT = NO)			               */

/* BYVARS:       BY VARIABLES IF ANY				         */

/* DEP_VARS:     DEPENDENT VARIABLE FOR YOUR MODEL                   */

/* IND_VARS:     INDEPENDENT VARIABLES FOR YOUR MODEL                */

/* IMPUTED_VARS: IMPUTED VARIABLES FOR YOUR MODEL                    */

/* LINK:         LINK specifies the link function that links the 	   */

/*		     response probabilities to the linear predictors     */

/*	  	     for non multiple imputed data				   */

/*				(DEFAULT IS LOGIT)		      	   */

/*                      (OPTION IS GLOGIT)        		  	   */

/* SORT_ORDER:   SORTING ORDER OF DEPENDENT VARIABLE                 */

/*               SEE SAS DOCUMENTTATION FOR DETAILS		 	   */  

/* CLASSVARS:    									   */

/*   INDEPENDENT CLASSIFICATION VARIABLES AND SORTING OPTIONS IF ANY */

/* CL:  	     CONFIDENCE LEVEL (DEFAULT IS 95) 			   */

/* DF:  		 DEGREES OF FREEDOM DEFINITION                     */

/*					(DEFAULT IS RUBIN99)		    	   */

/*                            (OPTION IS RUBIN87)             	   */

/* TITLE1:       TITLE 1 FOR OUTPUT						   */

/* TITLE2:       TITLE 2 FOR OUTPUT					 	   */

/* TITLE3:       TITLE 3 FOR OUTPUT					 	   */

/* TITLE4:       TITLE 4 FOR OUTPUT					 	   */

/* TITLE5:       TITLE 5 FOR OUTPUT					 	   */

/* XOUTPUT       PRINT EXTRA OUTPUT (DEFAULT IS NO)      		   */

/* REP_WT:       NUMBER OF REPLICATE WEIGHTS              	   	   */

/*				(DEFAULT IS 44)	      			   */

/*                      (OPTION IS 20)            			   */

/* IMPUTATIONS:  NUMBER OF IMPUTATIONS (DEFAULT = 5)			   */

/*									  		   */

/* COMPARE MODEL PARAMETER ESTIMATES   					   */ 

/* 		FOR NON IMPUTED DATA						   */

/*			WEIGHTED AND UNWEIGHTED 				   */

/*				PROC LOGISTIC and PROC SURVEYLOGISTIC: 	   */

/*											   */

/*		With LINK = LOGIT use “TEST” statement.       		   */

/*		With LINK = GLOGIT use “CONTRAST” statement.  		   */

/*											   */

/* 		FOR IMPUTED DATA							   */

/*			WEIGHTED AND UNWEIGHTED 				   */

/*				PROC MIANALIZE: USE TEST STATEMENT		   */

/*											   */

/* COMPARE1:                      						   */

/* COMPARE2:                      						   */

/* COMPARE3:                      						   */

/* COMPARE4:                      						   */

/* COMPARE5:                      						   */

/* COMPARE6:          			            			   */

/* COMPARE7:       			            			   */

/* COMPARE8:                      						   */

/* COMPARE9:                      				 		   */

/**********************************************************************/

**%PROC_LOGISTIC**(DSN = , 

 	      FORMAT = , 

	 USE_WEIGHTS = ,

            BYVARS = ,

	    DEP_VARS = , 

	    IND_VARS = , 

	IMPUTED_VARS = , 

    	        LINK = ,

	  SORT_ORDER = , 

	   CLASSVARS = ,

		    CL = , 

                DF = , 

		TITLE1 = ,

		TITLE2 = ,

		TITLE3 = ,

		TITLE4 = ,

		TITLE5 = ,

  	     XOUTPUT = ,

	  	REP_WT = ,

   	 IMPUTATIONS = ,

	    COMPARE1 = ,

	    COMPARE2 = ,

	    COMPARE3 = ,

	    COMPARE4 = ,

	    COMPARE5 = ,

	    COMPARE6 = ,

	    COMPARE7 = ,

	    COMPARE8 = ,

	    COMPARE9 = );

****

The following examples for the PROC_LOGISTIC macro can all be modified by adding variables to the BYVARS argument.  The results will be presented by the levels of those variables.  All examples perform comparison of regression coefficients.

Also more than one dependent variable maybe included in the DEP_VARS argument.  This will result on analysis for models with different dependent variables with the same independent variables.  

For the “COMPAREn” arguments only one equation can be used per argument.  For example: “COMPARE1 = aplus: **TEST** a1 + a2 = 1”.  

**Example 1:**

**Un-weighted non-imputed data**

MODEL: X = Y1 + Y2 + Y3 (Using un-weighted data, default sort order and no classification variables)   

With the LINK = LOGIT option use **TEST** statement.

%***PROC_LOGISTIC***(DSN = ALL, 

       USE_WEIGHTS = no,

  	  DEP_VARS = X, 

	  IND_VARS = Y1 Y2 Y3,

	      LINK = LOGIT,

        COMPARE1 = TEST_Y1_Y2: **TEST** Y1-Y2=**0**,

        COMPARE2 = TEST_Y1_Y3: **TEST** Y1-Y3=**0**);

With the LINK = GLOGIT option use **CONTRAST** statement.

%***PROC_LOGISTIC***(DSN = ALL, 

       USE_WEIGHTS = no,

  	  DEP_VARS = X, 

	  IND_VARS = Y1 Y2 Y3,

	      LINK = GLOGIT,

        COMPARE1 = **CONTRAST** 'Y1_Y2' Y1 **1** Y2 -**1**,

        COMPARE2 = **CONTRAST** 'Y1_Y3' Y1 **1** Y3 -**1**);

**Example 2:**

**Weighted non-imputed data**

MODEL: X = Y1 + Y2 + Y3 (Using weighted data, default sort order and no classification variables)

With the LINK = LOGIT option use **TEST** statement.

%**PROC_LOGISTIC**(DSN = ALL, 

       USE_WEIGHTS = YES,

          DEP_VARS = X, 

          IND_VARS = Y1 Y2 Y3,

	        LINK = LOGIT,

          COMPARE1 = TEST_Y1_Y2: **TEST** Y1-Y2=**0**,

          COMPARE2 = TEST_Y1_Y3: **TEST** Y1-Y3=**0**);

With the LINK = GLOGIT option use **CONTRAST** statement.

%**PROC_LOGISTIC**(DSN = ALL, 

       USE_WEIGHTS = YES,

          DEP_VARS = X, 

          IND_VARS = Y1 Y2 Y3,

	        LINK = GLOGIT,

          COMPARE1 = **CONTRAST** 'Y1_Y2' Y1 **1** Y2 -**1**,

          COMPARE2 = **CONTRAST** 'Y1_Y3' Y1 **1** Y3 -**1**);

**Example 3:**

**Un-weighted multiply imputed data**

MODEL: X  =  Y1 + Y2 + Y3 + W n + Zn  (Using un-weighted data, default sort order, and no classification variables)  Use TEST statement for un-weighted imputed data to compare the parameter estimates with the MULT option.

%***PROC_LOGISTIC***(DSN = ALL, 

       USE_WEIGHTS = NO,

 	    DEP_VARS = X, 

	    IND_VARS = Y1 Y2 Y3,

      IMPUTED_VARS = WM ZM,

   SORT_ORDER = ,

         COMPARE1 = **TEST** Y1 - Y2 / MULT,

         COMPARE2 = **TEST** W – Z / MULT);

**Example 4:**

**Weighted multiply imputed data**

MODEL: X  =  Y1 + Y2 + Y3 + Wn + Zn (Using weighted data, sort order of dependent variable is set to INTERNAL, and no classification variables are used.)  Use TEST statement for weighted imputed data to compare the parameter estimates with the MULT option.

%***PROC_LOGISTIC***(DSN = ALL, 

       USE_WEIGHTS = yes,

	    DEP_VARS = X, 

	    IND_VARS = Y1 Y2 Y3,

      IMPUTED_VARS = WM ZM,

  SORT_ORDER = INTERNAL,

         COMPARE1 = **TEST** Y1 - Y2 / MULT,

         COMPARE2 = **TEST** Y1 - Y3 / MULT,

         COMPARE3 = **TEST** Y2 - Y3 / MULT,

         COMPARE4 = **TEST** W – Z / MULT);

1

# image3.png

# image1.png

# image2.png