****************************************************
*
* Figure A4: Historical newspapers: Data description
*
****************************************************
 
global program "FigureA4"

cap log close
cap log using "$log_files/log_$program$today", replace

clear all
set mem 2g
set more off
set matsize 11000

***************************
***** 1. PREPARE DATA *****
***************************

// Get data

use "$data/Data_Chronicling", clear

****************************
***** 2. EXPORT FIGURE *****
****************************

// Newspapers by month and politician

preserve

collapse (sum) nwsp_=newspaper_count, by(politician month)

reshape wide nwsp_, i(month) j(politician) string

twoway (bar nwsp_Bryan month,  barwidth(0.7) color(blue%30) xlabel(#12, valuelabel labsize(vsmall))) ///
	   (bar nwsp_McKinley month,  barwidth(0.7) color(red%50) xlabel(#12, valuelabel labsize(vsmall)  )), ///
		ytitle("# Mentions") title("Newspaper Mentions by Month") ///
		xtitle("Month of 1896") ///
		legend(label(1 "William J. Bryan") label(2 "William McKinley")) scheme(burd)  name("month", replace) 

restore
		
// Newspapers by state and politician

preserve

collapse (sum) nwsp_=newspaper_count, by(politician state)

reshape wide nwsp_, i(state) j(politician) string

encode state, gen(state_n)

twoway (bar nwsp_Bryan state_n, barwidth(0.7) color(blue%25) xlabel(#50, valuelabel labsize(vsmall)  angle(vertical))) ///
		(bar nwsp_McKinley state_n, barwidth(0.7) color(red%50) xlabel(#50, valuelabel labsize(vsmall)  angle(vertical))), ///
		ytitle("# Mentions") title("Newspaper Mentions by State") ///
		xtitle("State") ///
		legend(label(1 "William J. Bryan") label(2 "William McKinley")) scheme(burd) name("state", replace) 
restore

// Combine 

graph combine month state, ysize(3) xsize(8)
graph export "$figures/$program.pdf", replace
