/* Create state-level measurement and merge it with a county-level dataset */ /* County-level dataset */ use SOCY401-Neustadtl-County-Crime.dta, clear /* Create state-level crime rate variable */ preserve collapse statecrim=crimerate04, by(state) sort state save statetemp, replace list restore /* Merge the state-level data with the county-level data */ merge m:1 state using statetemp erase statetemp.dta