Sample Code to Pool Multiple Cycles of CHIS Data

print share

Sample Code to Pool Multiple Cycles


The following SAS/SUDAAN and Stata codes show how to combine CHIS 2013 and 2014 data files and to create weights accounting for the multi-year files.


SAS/SUDAAN
:

data combined; /*this step concatenates the data files*/

 set libname.chis 2013 data (in=in13) libname.chis 2014 data (in=in14);

  if      in13 then year=2013;

  else if in14 then year=2014;

  ***Create new weight variables;

  fnwgt0 = rakedw0/2;

  array a_origwgts[80] rakedw1-rakedw80;

array a_newwgts[160] fnwgt1-fnwgt160;

do i = 1 to 80;

    if year=2013 then do;

      a_newwgts[i]    = a_origwgts[i]/2;

      a_newwgts[i+80] = rakedw0/2;

    end;

    else if year=2014 then do;

      a_newwgts[i]    = rakedw0/2;

      a_newwgts[i+80] = a_origwgts[i]/2;

    end;

  end;

run;

Stata:

log using "folder location\data_step.log", replace

***CHIS 2013 Adult data****

use "your folder location\CHIS 2013 data"

gen year=2013

gen fnwgt0=rakedw0/2

for new fnwgt1-fnwgt160: gen X=0

foreach i of numlist 1/80{

            local j=`i'-0

            replace fnwgt`i'=rakedw`j'/2

}

foreach i of numlist 81/160{

            replace fnwgt`i'=rakedw0/2

}

save adult13 , replace

***CHIS 2014 Adult data****

use "folder location\CHIS 2014 data"

gen year=2014

gen fnwgt0=rakedw0/2

for new fnwgt1-fnwgt160: gen X=0

foreach i of numlist 1/80{           

            replace fnwgt`i'=rakedw0/2

}

foreach i of numlist 81/160{

            local j=`i'-80

            replace fnwgt`i'=rakedw`j'/2

}

append using adult13 /*this step concatenates the data files*/

save "folder location\combined.dta", replace


After creating the new weights in your pooled file, you need to call them in your analyses. The following code snippets describe design statements that must be used in your SAS/SUDAAN or Stata procedures to analyze the combined dataset.  The Stata examples work with Stata Version 12-14.  The Stata design statement (svyset) is needed before the analysis. It does not need to be repeated for each analysis in Stata, once applied.


SAS:

/* Weights are called in each procedure using the “weight”,  “repweight” statements, with the jkcoef=1 option to specify jackknife…estimator

   NOTE: “varmethod = jackknife” must also be specified after the “data =” statement */

PROC PROCEDURENAME data = combined varmethod = jackknife;

  weight fnwgt0;

  repweight fnwgt1-fnwgt160 / jkcoef = 1;

SUDAAN:

/* SUDAAN specs are very similar to SAS, but notice that jackknife is specified with “design =”the replicate weights are specified as “jackwgts”, and “adjjack=1” specifies the estimator (like jkcoef = 1 in SAS) */

PROC PROCEDURENAME data = combined design = jackknife;

  weight fnwgt0;

;

Stata:

/* In Stata, the complex design can be specified once for the entire Stata session (rather than in each proc separately, as SAS requires. Note the parallel references to your new variables after “svyset” below

“[pw = fngwt0]” tells Stata that the weight is a person-weight

“j

vce (jack)” specifies that jackknife estimation should be used

“mse” Tells Stata to use the MSE (mean square error) formula to calculate the variance across the replicates

After this specification, any “svy” commands you run will use its specification. */

use "folder location\combined.dta"

svyset [pw=fnwgt0], jkrw(fnwgt1-fnwgt160, multiplier(1)) vce (jack) mse