/* Set up datasets for merge/append examples */ local datadir "C:\Documents and Settings\HP_Owner\My Documents\My Research\County Level Data\" local workdir "C:\Documents and Settings\HP_Owner\My Documents\My Classes\SOCY602\Stata usersite\SOCY498C\merge\merge v11\" cd "`workdir'" /* Create separate State/County datasets */ foreach num of numlist 21 9 47 { use statename countyname county fips pop00 pop01 pop02 pop03 pop04 pop05 using "`datadir'counties" if statename==`num', clear save state`num' } copy state21.dta md.dta, replace copy state9.dta dc.dta, replace copy state47.dta va.dta, replace erase state21.dta erase state9.dta erase state47.dta /* Create births dataset for all counties */ use statename countyname county births4_7_00 births01 births02 births03 births04 births05 using "`datadir'counties", clear save countybirths, replace cd "`workdir'" /* Create datasets for each population variable per year */ foreach sname in md dc va { foreach vname in pop00 pop01 pop02 pop03 pop04 pop05 { use statename countyname county fips `vname' using `sname', clear save `sname'`vname', replace } }