/*----------------------------------------------------------------------
 
 REPLICATION FILE FOR
 Gerber, Alan S., Gregory A. Huber, Albert H. Fang, and Andrew Gooch. (Forthcoming)
 "The Generalizability of Social Pressure Effects on Turnout Across High-Salience Electoral Contexts:
  Field Experimental Evidence from 1.96 Million Citizens in 17 States"
 American Politics Research
 
 FILE: 			01_CreatePublicDataset.do
 DESCRIPTION: 	Creates public dataset (provided to show how the file is created only)
 DATE: 			14 Dec 2016
 VERSION: 		1.0

----------------------------------------------------------------------*/
* Load data
use "../AnalyzeData/DeidentifiedData/VPC_InconsistentVotersExp_NoPII.dta", clear
des

* Create salience score
gen salience = .
replace salience = 3 if state == "AR"
replace salience = 4 if state == "AK"
replace salience = 1 if state == "AZ"
replace salience = 4 if state == "CO"
replace salience = 2 if state == "FL"
replace salience = 4 if state == "GA"
replace salience = 3 if state == "IA"
replace salience = 4 if state == "KS"
replace salience = 1 if state == "KY"
replace salience = 2 if state == "LA"
replace salience = 3 if state == "ME"
replace salience = 3 if state == "MI"
replace salience = 2 if state == "NC"
replace salience = 3 if state == "NH"
replace salience = 2 if state == "SD"
replace salience = 2 if state == "TX"
replace salience = 2 if state == "WI"
tab salience, m
tab state salience, m

* Create high-salience indicator
gen hi_salience = 0
replace hi_salience = 1 if salience == 3 | salience == 4
tab salience hi_salience, m
tab state hi_salience, m



* Rename identifier variables
rename resid id
label var id "Person ID"
rename vpc_household_id hhid
label var hhid "Household ID"

* Reorder variables
order id hhid state treat voted* i_age age_miss age2

* Label all unlabeled variables
label var salience "Ex Ante Election Salience Score"
label var hi_salience "High Ex Ante Election Salience"
label var flag_hhid_mult_hhid "Flag: 1=Drop record, VPC Household ID is invalid" 
label var flag_hhid_mult_z "Flag: 1=Drop record, subjects in HH assigned to diff treatments"
label var flag_drop_hhid "Flag: 1=Drop record due to VPC randomization error"

label var ipw_p_noex "IPW for Sensitivity Analysis: No sample exclusions"
label var ipw_p_vvh "IPW for Sensitivity Analysis: Excl. if VH unknown"
label var ipw_p_exnclt23_vvh "IPW for Sensitivity Analysis: Excl. if VH unknown, under 23 in NC"
label var ipw_h_vvhvid "IPW for Sensitivity Analysis: Excl. if VH unknown, HH size > 1"
label var ipw_h_exnclt23_vvhvid "IPW for Main Analysis Sample: Excl. if VH unknown, HH size > 1, under 23 in NC"
label var ipw_p_vvhvid "IPW for Diagnostic Randomization Checks: Excl. if VH unknown, HH size > 1"
label var ipw_sh_exnclt23 "IPW for Est by VH Stratum: Excl. if VH unknown, HH size > 1, under 23 in NC"
label var vote_hist "Of Last 4 Elections where Subject Eligible to Vote, Number of Elections Voted"

tab vote_hist, m

* Drop variables not necessary for analysis
foreach y in 2006 2008 2009 2010 2011 2012 2013 2014 {
drop vote_`y'
}
drop v_race_black v_gender_female filenum age agecat /// 
	race gender married r_race r_gend r_married ///
	cdid cdmatch ipw_h_exnclt23_vvh ipw_h_exnclt23_vid ipw_h_exnclt23_noex ipw_p_exnclt23 ipw_p_vid ipw_h_exnclt23_vvhvid_cd

des
compress

* Save public replication dataset (Stata 12 version)
saveold PublicReplicationData.dta, replace version(12)
