1 Downloading data from the NHANES website

2 Import Sociodemographic XPT

The following STATA chunk imports and describes the sociodemographic NHANES dataset:

import sasxport5 "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\DEMO_E.XPT"
save "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_DEMO_E.dta",replace
de
clear
file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_DEMO_E.dta saved


Contains data from C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_DEMO_
> E.dta
 Observations:        10,149                  
    Variables:            43                  5 Jul 2021 15:55
-------------------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-------------------------------------------------------------------------------
seqn            double  %10.0g                Respondent sequence number
sddsrvyr        double  %10.0g                Data Release Number
ridstatr        double  %10.0g                Interview/Examination Status
ridexmon        double  %10.0g                Six month time period
riagendr        double  %10.0g                Gender
ridageyr        double  %10.0g                Age at Screening Adjudicated -
                                                Recode
ridagemn        double  %10.0g                Age in Months at Screening -
                                                Recode
ridageex        double  %10.0g                Age in Months at Exam - Recode
ridreth1        double  %10.0g                Race/Ethnicity - Recode
dmqmilit        double  %10.0g                Served in the US Armed Forces
dmdborn2        double  %10.0g                Country of Birth - Recode
dmdcitzn        double  %10.0g                Citizenship Status
dmdyrsus        double  %10.0g                Length of time in US
dmdeduc3        double  %10.0g                Education Level - Children/Youth
                                                6-19
dmdeduc2        double  %10.0g                Education Level - Adults 20+
dmdschol        double  %10.0g                Now attending school?
dmdmartl        double  %10.0g                Marital Status
dmdhhsiz        double  %10.0g                Total number of people in the
                                                Household
dmdfmsiz        double  %10.0g                Total number of people in the
                                                Family
indhhin2        double  %10.0g                Annual Household Income
indfmin2        double  %10.0g                Annual Family Income
indfmpir        double  %10.0g                Ratio of family income to poverty
ridexprg        double  %10.0g                Pregnancy Status at Exam - Recode
dmdhrgnd        double  %10.0g                HH Ref Person Gender
dmdhrage        double  %10.0g                HH Ref Person Age
dmdhrbr2        double  %10.0g                HH Ref Person Country of Birth
dmdhredu        double  %10.0g                HH Ref Person Education Level
dmdhrmar        double  %10.0g                HH Ref Person Marital Status
dmdhsedu        double  %10.0g                HH Ref Person's Spouse Education
                                                Level
sialang         double  %10.0g                Language of SP Interview
siaproxy        double  %10.0g                Proxy used in SP Interview?
siaintrp        double  %10.0g                Interpreter used in SP Interview?
fialang         double  %10.0g                Language of Family Interview
fiaproxy        double  %10.0g                Proxy used in Family Interview?
fiaintrp        double  %10.0g                Interpreter used in Family
                                                Interview?
mialang         double  %10.0g                Language of MEC Interview
miaproxy        double  %10.0g                Proxy used in MEC Interview?
miaintrp        double  %10.0g                Interpreter used in MEC
                                                Interview?
aialang         double  %10.0g                Language of ACASI Interview
wtint2yr        double  %10.0g                Full Sample 2 Year Interview
                                                Weight
wtmec2yr        double  %10.0g                Full Sample 2 Year MEC Exam
                                                Weight
sdmvpsu         double  %10.0g                Masked Variance Pseudo-PSU
sdmvstra        double  %10.0g                Masked Variance Pseudo-Stratum
-------------------------------------------------------------------------------
Sorted by: 

3 Import Body Measures XPT

a

The following STATA chunk imports and describes the body measures NHANES dataset:

import sasxport5 "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\BMX_E.XPT"
save "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_BMX_E.dta",replace
de
clear
file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_BMX_E.dta saved


Contains data from C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_BMX_E
> .dta
 Observations:         9,762                  
    Variables:            23                  5 Jul 2021 15:55
-------------------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-------------------------------------------------------------------------------
seqn            double  %10.0g                Respondent sequence number
bmdstats        double  %10.0g                Body Measures Component Status
                                                Code
bmxwt           double  %10.0g                Weight (kg)
bmiwt           double  %10.0g                Weight Comment
bmxrecum        double  %10.0g                Recumbent Length (cm)
bmirecum        double  %10.0g                Recumbent Length Comment
bmxhead         double  %10.0g                Head Circumference (cm)
bmihead         double  %10.0g                Head Circumference Comment
bmxht           double  %10.0g                Standing Height (cm)
bmiht           double  %10.0g                Standing Height Comment
bmxbmi          double  %10.0g                Body Mass Index (kg/m**2)
bmxleg          double  %10.0g                Upper Leg Length (cm)
bmileg          double  %10.0g                Upper Leg Length Comment
bmxarml         double  %10.0g                Upper Arm Length (cm)
bmiarml         double  %10.0g                Upper Arm Length Comment
bmxarmc         double  %10.0g                Arm Circumference (cm)
bmiarmc         double  %10.0g                Arm Circumference Comment
bmxwaist        double  %10.0g                Waist Circumference (cm)
bmiwaist        double  %10.0g                Waist Circumference Comment
bmxtri          double  %10.0g                Triceps Skinfold (mm)
bmitri          double  %10.0g                Triceps Skinfold Comment
bmxsub          double  %10.0g                Subscapular Skinfold (mm)
bmisub          double  %10.0g                Subscapular Skinfold Comment
-------------------------------------------------------------------------------
Sorted by: 

b

The following STATA chunk imports the body measures NHANES dataset, keeps only the needed variables, saves and describes the resulting data subset:

import sasxport5 "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\BMX_E.XPT"
keep seqn bmdstats bm*wt bm*ht bmxbmi bm*waist
save "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_BMX_E.dta",replace
de
clear
file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_BMX_E.dta saved


Contains data from C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_BMX_E
> .dta
 Observations:         9,762                  
    Variables:             9                  5 Jul 2021 15:55
-------------------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-------------------------------------------------------------------------------
seqn            double  %10.0g                Respondent sequence number
bmdstats        double  %10.0g                Body Measures Component Status
                                                Code
bmxwt           double  %10.0g                Weight (kg)
bmiwt           double  %10.0g                Weight Comment
bmxht           double  %10.0g                Standing Height (cm)
bmiht           double  %10.0g                Standing Height Comment
bmxbmi          double  %10.0g                Body Mass Index (kg/m**2)
bmxwaist        double  %10.0g                Waist Circumference (cm)
bmiwaist        double  %10.0g                Waist Circumference Comment
-------------------------------------------------------------------------------
Sorted by: 

c import diet behaviour and nutrition

import sasxport5 "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\DBQ_E.XPT"
keep seqn dbq360 dbd381 dbq400 dbd411 dbq421
save "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_DBQ_E.dta",replace
de
clear
file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_DBQ_E.dta saved


Contains data from C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_DBQ_E
> .dta
 Observations:        10,149                  
    Variables:             6                  5 Jul 2021 15:55
-------------------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-------------------------------------------------------------------------------
seqn            double  %10.0g                Respondent sequence number
dbq360          double  %10.0g                Attend kindergarten thru high
                                                school
dbd381          double  %10.0g                # of times/week get school lunch
dbq400          double  %10.0g                School serve complete breakfast
                                                each day
dbd411          double  %10.0g                # of times/week get school
                                                breakfast
dbq421          double  %10.0g                School breakfast
                                                free/reduced/full price
-------------------------------------------------------------------------------
Sorted by: 

d import health insurance

import sasxport5 "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\HIQ_E.XPT"
keep seqn hiq011 hiq031a  hiq031b hiq031c hiq031d hiq031e hiq031f hiq031g hiq031h hiq031i hiq031j hiq031aa
save "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_HIQ_E.dta",replace
de
clear
file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_HIQ_E.dta saved


Contains data from C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_HIQ_E
> .dta
 Observations:        10,149                  
    Variables:            13                  5 Jul 2021 15:55
-------------------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-------------------------------------------------------------------------------
seqn            double  %10.0g                Respondent sequence number
hiq011          double  %10.0g                Covered by health insurance
hiq031a         double  %10.0g                Covered by private insurance
hiq031b         double  %10.0g                Covered by Medicare
hiq031c         double  %10.0g                Covered by Medi-Gap
hiq031d         double  %10.0g                Covered by Medicaid
hiq031e         double  %10.0g                Covered by SCHIP
hiq031f         double  %10.0g                Covered by military health care
hiq031g         double  %10.0g                Covered by Indian Health Service
hiq031h         double  %10.0g                Covered by state-sponsored health
                                                plan
hiq031i         double  %10.0g                Covered by other government
                                                insurance
hiq031j         double  %10.0g                Covered by single service plan
hiq031aa        double  %10.0g                No coverage of any type
-------------------------------------------------------------------------------
Sorted by: 

4 Import Food Security XPT

a

The following STATA chunk imports and describes the Food Security NHANES dataset:

import sasxport5 "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\FSQ_E.XPT"
#save "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_FSQ_E.dta",replace
de
clear
Unknown #command

Contains data
 Observations:        10,149                  
    Variables:            44                  
-------------------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-------------------------------------------------------------------------------
seqn            double  %10.0g                Respondent sequence number
fsd032a         double  %10.0g                HH Worried run out of food
fsd032b         double  %10.0g                HH Food didn't last
fsd032c         double  %10.0g                HH Couldn't afford balanced meals
fsd032d         double  %10.0g                HH Relied on low-cost food for
                                                child
fsd032e         double  %10.0g                HH Couldn't feed child balanced
                                                meal
fsd032f         double  %10.0g                HH Child not eating enough
fsd041          double  %10.0g                HH Adults cut size or skip meals
fsd052          double  %10.0g                HH How often adults cut size/skip
                                                meals
fsd061          double  %10.0g                HH Eat less than should
fsd071          double  %10.0g                HH Hungry, but didn't eat
fsd081          double  %10.0g                HH Lost weight, no money for food
fsd092          double  %10.0g                HH Adults not eat whole day
fsd102          double  %10.0g                HH How often adults not eat for
                                                day
fsd111          double  %10.0g                HH Cut size of child meals
fsd122          double  %10.0g                HH Child skip meals
fsd132          double  %10.0g                HH How often child skip meals
fsd141          double  %10.0g                HH Child hungry in last 12 months
fsd146          double  %10.0g                HH Child not eat whole day
fsdhh           double  %10.0g                Household food security category
fsdad           double  %10.0g                Adult food security category
fsdch           double  %10.0g                Child food security category
fsd151          double  %10.0g                HH Emergency food received
fsd401          double  %10.0g                Meal size cut
fsd411          double  %10.0g                Skipped meals
fsd421          double  %10.0g                Ate less than should
fsd431          double  %10.0g                Hungry
fsq440          double  %10.0g                Lost weight
fsd451          double  %10.0g                Not eat whole day
fsq165          double  %10.0g                HH FS benefit: ever received
fsq171          double  %10.0g                HH FS benefit: receive in last 12
                                                months
fsd225          double  %10.0g                HH FS benefit: time since last
                                                received
fsq235          double  %10.0g                HH FS benefit: amount received
                                                last time
fsq162          double  %10.0g                HH WIC benefit: receive in last
                                                12 month
fsd650zc        double  %10.0g                CH WIC benefit: receive in last
                                                12 month
fsd660zc        double  %10.0g                CH WIC benefit: currently receive
fsd675          double  %10.0g                CH WIC benefit: received in
                                                infancy
fsd680          double  %10.0g                CH WIC benefit: received b/w 1-4
                                                yrs old
fsd670zc        double  %10.0g                CH WIC benefit: # of months
                                                received
fsq690          double  %10.0g                CH WIC benefit: Mom received
                                                while preg.
fsq695          double  %10.0g                CH WIC benefit: starting month of
                                                preg.
fsd650zw        double  %10.0g                WM WIC benefit: receive in last
                                                12 month
fsd660zw        double  %10.0g                WM WIC benefit: currently receive
fsd670zw        double  %10.0g                WM WIC benefit: # of months
                                                received
-------------------------------------------------------------------------------
Sorted by: 
     Note: Dataset has changed since last saved.

b

The following STATA chunk imports the food security NHANES dataset, keeps only the needed variables, saves and describes the resulting data subset:

import sasxport5 "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\FSQ_E.XPT"
keep seqn fsdch
save "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_FSQ_E.dta",replace
de
clear
file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_FSQ_E.dta saved


Contains data from C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_FSQ_E
> .dta
 Observations:        10,149                  
    Variables:             2                  5 Jul 2021 15:55
-------------------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-------------------------------------------------------------------------------
seqn            double  %10.0g                Respondent sequence number
fsdch           double  %10.0g                Child food security category
-------------------------------------------------------------------------------
Sorted by: 

5 Merge files

c demographics and body measurement files

use "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_DEMO_E.dta", clear
save "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\NHANES0708_merged.dta",replace
merge 1:1 seqn using "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_BMX_E.dta"
rename _merge Merge_BM
tab Merge_BM
duplicates report seqn
save,replace
file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\NHANES0708_merged.dta
    saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                           387
        from master                       387  (_merge==1)
        from using                          0  (_merge==2)

    Matched                             9,762  (_merge==3)
    -----------------------------------------



   Matching result from |
                  merge |      Freq.     Percent        Cum.
------------------------+-----------------------------------
        Master only (1) |        387        3.81        3.81
            Matched (3) |      9,762       96.19      100.00
------------------------+-----------------------------------
                  Total |     10,149      100.00


Duplicates in terms of seqn

--------------------------------------
   Copies | Observations       Surplus
----------+---------------------------
        1 |        10149             0
--------------------------------------

file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\NHANES0708_merged.dta
    saved

d merge food security data into main dataset

use "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\NHANES0708_merged.dta", clear
merge 1:1 seqn using "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_FSQ_E.dta"
rename _merge Merge_FS
tab Merge_FS
duplicates report seqn
save,replace
    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                            10,149  (_merge==3)
    -----------------------------------------



   Matching result from |
                  merge |      Freq.     Percent        Cum.
------------------------+-----------------------------------
            Matched (3) |     10,149      100.00      100.00
------------------------+-----------------------------------
                  Total |     10,149      100.00


Duplicates in terms of seqn

--------------------------------------
   Copies | Observations       Surplus
----------+---------------------------
        1 |        10149             0
--------------------------------------

file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\NHANES0708_merged.dta
    saved

6 Merge additional datasets

a merge diet & nutrition data into main dataset

use "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\NHANES0708_merged.dta", clear
merge 1:1 seqn using "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_DBQ_E.dta"
rename _merge Merge_DB
tab Merge_DB
duplicates report seqn
save,replace
    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                            10,149  (_merge==3)
    -----------------------------------------



   Matching result from |
                  merge |      Freq.     Percent        Cum.
------------------------+-----------------------------------
            Matched (3) |     10,149      100.00      100.00
------------------------+-----------------------------------
                  Total |     10,149      100.00


Duplicates in terms of seqn

--------------------------------------
   Copies | Observations       Surplus
----------+---------------------------
        1 |        10149             0
--------------------------------------

file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\NHANES0708_merged.dta
    saved

b merge health insurance data into main dataset

use "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\NHANES0708_merged.dta", clear
merge 1:1 seqn using "C:\Users\Matt\Documents\EPI536\EPI536-Assignments\temp_HIQ_E.dta"
rename _merge Merge_HI
tab Merge_HI
duplicates report seqn
save,replace
    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                            10,149  (_merge==3)
    -----------------------------------------



   Matching result from |
                  merge |      Freq.     Percent        Cum.
------------------------+-----------------------------------
            Matched (3) |     10,149      100.00      100.00
------------------------+-----------------------------------
                  Total |     10,149      100.00


Duplicates in terms of seqn

--------------------------------------
   Copies | Observations       Surplus
----------+---------------------------
        1 |        10149             0
--------------------------------------

file C:\Users\Matt\Documents\EPI536\EPI536-Assignments\NHANES0708_merged.dta
    saved