** RP 11-14 ** cd "/Users/edwardwith/Desktop/Regression Analysis/RP/EW&BM RP stata" use Poverty.dta, clear des offpov tab year, sum(offpov) ** Trying to import CSV ** import csv clear save "Alabama.csv", replace numlabel, add br gen Alabama=0 replace Alabama=1 if ****** use "legal_gambling_states.dta", clear merge 1:1 state_fips using "usa_map_crosswalk.dta" ** Table ** **Cleaning** tab _merge drop if _merge==2 drop if state_fip==15 drop if state_fip==2 drop _merge **Drops random columns** drop G H I J K **creates basic data set with state coordinates and binary values and credit scores save "legal_gambling_states.dta", replace spmap legal_gambling using us_map_coordinates.dta, id(id) /// fcolor(white red) clmethod(unique) /// legend(label(2 "Sports Gambling Illegal")label(3 "Sports Gambling Legal")) legtitle("Legend") title("Map of Legal Sports Betting in the USA") graph export "/Users/malachisd/Library/CloudStorage/GoogleDrive-mshifferdelegard@middlebury.edu/My Drive/Econ_0111/Final Research project/MSD&EW Replication Package/Output/StateMap.jpg", as(jpg) name("Graph") quality(90) **Merging census data to gambling data** use legal_gambling_states.dta, clear merge 1:1 state_fips using US_ACS_census_2010.dta destring legal_gambling, replace drop if _merge==2 drop if _merge==1 drop _merge **generating gambling market launch indicator** gen Legal_gambling_affect = . destring Legal_gambling_affect, replace destring YearMarketLaunched, replace replace Legal_gambling_affect = 1 if legal_gambling == 1 & YearMarketLaunched <= 2021 replace Legal_gambling_affect = 0 if Legal_gambling_affect==. save legal_gambling.dta, replace **ttest and CI plot** ttest AverageCreditScore, by(Legal_gambling_affect) matrix results = r(mu_1), r(mu_1)-1.96*(r(sd_1)/sqrt(r(N_1))) , r(mu_1)+1.96*(r(sd_1)/sqrt(r(N_1))) matrix results = results \ r(mu_2), r(mu_2)-1.96*(r(sd_2)/sqrt(r(N_2))) , r(mu_2)+1.96*(r(sd_2)/sqrt(r(N_2))) return list matrix list results matrix colnames results = mean ll ul matrix rownames results = gambling_illegal gambling_legal matrix list results coefplot matrix(results[,1]), ci((results[,2] results[,3])) /// vertical recast(bar) barwidth(.25) ciopts(recast(rcap) lcolor(black)) citop /// title(Sports Betting Legal vs Illegal) subtitle(Average Credit Score) /// note("p-value<.01") graph export "/Users/malachisd/Library/CloudStorage/GoogleDrive-mshifferdelegard@middlebury.edu/My Drive/Econ_0111/Final Research project/MSD&EW Replication Package/Output/CI Visual.jpg", as(jpg) name("Graph") quality(90) **Balance table** global controls "age elderly female citizen_US college married black asian white employed inctot" des $controls sum $controls return list ttest AverageCreditScore, by(Legal_gambling_affect) matrix balance = r(mu_1) , r(mu_2) , r(mu_2)-r(mu_1) , r(p) foreach x of varlist elderly female citizen_US college married black asian white employed inctot { ttest `x', by(Legal_gambling_affect) matrix balance = balance \ r(mu_1) , r(mu_2) , r(mu_2)-r(mu_1) , r(p) } matrix colnames balance = no_legal_betting legal_betting diff p_val matrix rownames balance = $controls matrix list balance putexcel set balance.xlsx, sheet(table_1) replace putexcel A1 = matrix(balance), names **Regression** reg AverageCreditScore Legal_gambling_affect reg AverageCreditScore Legal_gambling_affect citizen_US reg AverageCreditScore Legal_gambling_affect outreg2 using reg_results, replace reg AverageCreditScore Legal_gambling_affect citizen_US outreg2 using reg_results reg AverageCreditScore Legal_gambling_affect citizen_US college outreg2 using reg_results reg AverageCreditScore Legal_gambling_affect elderly female citizen_US college married black asian white employed inctot outreg2 using reg_results, excel