global program "EEREV-D-21-00004_TableB5"

cap log close
cap log using "$log\log_$program$today", replace

**** REPLICATION OF TABLE B5 ****

clear all
set mem 2g
set more off

/*	
	OUTLINE
	1. DESCRIPTIVES TABLE
*/

*********************************
***** 1. DESCRIPTIVES TABLE *****
*********************************

// Import candidate data

use $data\EEREV-D-21-00004_Data_Candidates.dta, clear

// Prepare variables

g Candidate=candidate

replace Candidate="Chaban-Delmas" 		if candidate=="ChabanDelmas"
replace Candidate="de Gaulle" 			if candidate=="DeGaulle"
replace Candidate="de Villiers" 		if candidate=="DeVilliers"
replace Candidate="Dupont-Aignan" 		if candidate=="DupontAignan"
replace Candidate="Giscard d'Estaing" 	if candidate=="GiscarddEstaing"
replace Candidate="Le Pen JM" 			if candidate=="LePen" 				& annee<=2007
replace Candidate="Le Pen M" 			if candidate=="LePen" 				& annee>2007
replace Candidate="Saint-Josse" 		if candidate=="SaintJosse"
replace Candidate="Tixier-Vignancour" 	if candidate=="TixierVignancour"
replace Candidate="H\'eraud" 			if candidate=="Heraud"
replace Candidate="Chev\\`enement" 		if candidate=="Chevenement"
replace Candidate="Mam\\`ere"	 		if candidate=="Mamere"
replace Candidate="M\'egret"	 		if candidate=="Megret"
replace Candidate="Bov\'e"	 			if candidate=="Bove"
replace Candidate="M\'elenchon"	 		if candidate=="Melenchon"

tostring annee, g(Election)
rename data Data

foreach var in poll neg_C nat_C aut_C rle_C{
	replace `var'=0 if `var'<0.0001 & `var'>-0.0001
}

g Polls=strofreal(poll)
g Radical=strofreal(neg_C)
g Nation=strofreal(nat_C)
g Authority=strofreal(aut_C)
g LRindex=strofreal(rle_C)

drop poll neg_C nat_C aut_C rle_C

replace Candidate=Candidate+" ("+Election+")"
drop Election

keep Candidate Data Polls Radical Nation Authority LRindex
order Candidate Data Polls Radical Nation Authority LRindex
sort Candidate

cd "$results"
*dataout, head tex replace save($program) dec(3) // Results exported manually

cap log close
