* NEED TO COPY INFORMATION BY HAND FROM STATA OUTPUT WINDOW -- CODE PAUSES AT APPROPRIATE PLACES

* TABLE 1: summary statistics
use i_ln_prisrate IHMEviolentdeaths IHMEdrugdeaths $ICVS $drugs $notimputable $imputable USA oecd year using paneldata.dta, clear
recode i_ln_prisrate IHMEviolentdeaths IHMEdrugdeaths $notimputable $imputable (* = .) if year!=2005 // only the drug and ICVS variables need other years
gen prisrate=exp(i_ln_p)
tabstat prisrate IHMEviolentdeaths $ICVS IHMEdrugdeaths $drugs $notimputable $imputable, statistics(n mean median sd) columns(statistics)
tabstat prisrate IHMEviolentdeaths $ICVS IHMEdrugdeaths $drugs $notimputable $imputable if USA, statistics(mean) columns(statistics)
tabstat prisrate IHMEviolentdeaths $ICVS IHMEdrugdeaths $drugs $notimputable $imputable if oecd & !USA, statistics(mean) columns(statistics)
pause // copy output of preceding three lines as tables & paste next to one another into Excel file!

* TABLE 2: missing values
program missingvalues
	qui misstable pattern $notimputable $imputable if !mi(`1')
	disp "Dependent variable: `1'"
	disp "total observations: `=r(N_complete)+r(N_incomplete)'"
	disp "incomplete observations: `r(N_incomplete)'"
	misstable sum $notimputable $imputable if !mi(`1')
	pause // need to copy information by hand
	end
	
use MIdataset.dta, clear // using these data sets ensures that any restrictions imposed on the regression samples propagate to table 2
mi extract 0
missingvalues i_ln_pris
missingvalues ln_IHMEviolentdeaths

use MI_ICVS_dataset.dta, clear
mi extract 0
missingvalues victim9
collapse $notimputable $imputable victim9_countries=victim9, by(numISO)
missingvalues victim9_countries

use MI_drugsWDR_dataset.dta, clear
mi extract 0
foreach drug of varlist $drugs {
	missingvalues `drug'
	}
	
clear
