Sunday, September 10, 2006

Updated do-file suggestions from Prof. Colman

Hi folks.

This posting is primarily for those currently taking microeconometrics. Here are updated do-files with the corrected paths:

(keep in mind that the don't come through well on the blog, so enter your dictionary file accordingly)

Dictionary file:

infile dictionary {
_lrecl(560)
_column(5) str10 hhid %10s "Household ID"
_column(15) str2 perno %2s "Person number"
_column(25) sex %1f "Sex"
_column(27) age %2f "Age"
_column(43) race1 %1f "Race"
_column(46) hispanic1 %2f "Hispanic origin"
_column(61) poverty %1f "Poverty status"
_column(67) family_size %1f "Family size"
_column(68) family_comp %1f "Family composition"
_column(70) health %1f "Perceived health status"
_column(71) act_limit %1f "Activity limitation"
_column(98) restrict_days %2f "Restricted activity days"
_column(182) region %1f "Region"
_column(201) wt %9f "Insurance sample weight"
_column(337) strata %4f "Strata"
_column(341) psu %1f "Primary sampling unit"
_column(410) medicaid1 %1f "Medicaid status"
}

Do-file:

clear
capture log close
set more off
set mem 40m

local insdct ""C:\Classes\Fall 2006\Hunter\Microeconometrics\NHIS\nhis95ins.dct""
local insdat ""C:\Classes\Fall 2006\Hunter\Microeconometrics\NHIS\HEALTHIN.DAT""
local insdta ""C:\Classes\Fall 2006\Hunter\Microeconometrics\NHIS\healthin.dta""

infile using `insdct', using(`insdat')

keep if age<18

/*
other variables needed:
age, sex, race, family size, family composition,
region, perceived health status, limitation of activity,
restricted activity days, and restricted activity days squared
*/

gen female=sex==2

/* customary race and ethnicity categories are non-hispanic white,
non-hispanic black, non-hispanic other, and hispanic
*/

/* We have to be sure that the race categories include everyone,
and do not overlap, so we create a new variable, race2, and then
create dummies */

gen race2=1 if race1==1 & hispanic1==10
replace race2=2 if race1==2 & hispanic1==10 & race2==.
replace race2=3 if race1==3 & hispanic1==10 & race2==.
replace race2=4 if hispanic1 !=10 & race2==.

gen nhwhite=race2==1
gen nhblack=race2==2
gen nhother=race2==3
gen hispanic=race2==4

gen poor=1 if poverty==2
replace poor=0 if poverty==1

gen northeast=region==1
gen midwest=region==2
gen south=region==3
gen west=region==4

gen health_excel=health==1 if health!=6
gen health_vgood=health==2 if health!=6
gen health_good=health==3 if health!=6
gen health_fair=health==4 if health!=6
gen health_poor=health==5 if health!=6

No comments: