sort year merge year using "C:\Users\Gretchen\OneDrive\Documents\NTA_GD_Personal\US_NTA\ct_Feb2017.dta" keep if _merge==3 drop _merge /* Make public sector summary variables and public transfer inflows for public consumption. (separate out medicare because it has a different tax/outflow profile). */ egen tgf_ct=rowtotal(tgfk_i_dom_fed_ct tgfk_i_dom_sl_ct tgfk_c_ct tgp_fica_ct tgp_smi_ct tgp_unemp_ct tgfp_own_ct tgfp_rnt_ct tgfg_alc_ct tgfg_tob_ct tgfg_oth_ct tgfx_fed_ct tgfx_sl_ct) egen tgf=rowtotal(tgfk_i_dom_fed tgfk_i_dom_sl tgfk_c tgp_fica tgp_smi tgp_unemp tgfp_own tgfp_rnt tgfg_alc tgfg_tob tgfg_oth tgfx_fed tgfx_sl) egen tgei=rowtotal(cge1 cge2 cge3) egen tghi_mcare=rowtotal(cgh1 cgh4 ) egen tghi_other=rowtotal(cgh2 cgh3 cgh5 cgh6a cgh6b cgh7) gen tghi=tghi_mcare+tghi_other egen tgxci=rowtotal(tgxci_u tgxci_x8 tgxci_i tgxci_x3 tgxci_x4 tgxci_f1 tgxci_x2 tgxci_x7 tgxci_x5 tgxci_x1 tgxci_f2 tgxci_x6 tgxci_f3 tgxci_f4 ) gen tgxii=cgx egen tgei_ct=rowtotal(cge1_ct cge2_ct cge3_ct) egen tghi_mcare_ct=rowtotal(cgh1_ct cgh4_ct ) egen tghi_other_ct=rowtotal(cgh2_ct cgh3_ct cgh5_ct cgh6a_ct cgh6b_ct cgh7_ct) gen tgxii_ct=cgx_ct bysort year: egen tgxci_ct=sum(tgxci*pop/1000000000) /* MAKE OUTFLOW MACRO CTRLS FOR PROGRAMS WITH EARMARKED TAXES (ET). - Education is paid for with property taxes - Social security is paid for with FICA taxes - Medicare (including SMI) is paid for with FICA taxes and SMI contributions. (could eventually investigate seperating state-level taxes and benefits from federal level, but grants-in-aid make it very messy, so leave it for now) If ET tax macro is more than program macro, shape will be all ET tax, with macro control equal to inflow macro control. If ET tax is less than program, shape will be part ET flow, and part general tax (GT) profile. */ gen tgfp_ct=tgfp_own_ct+tgfp_rnt_ct gen tgfp=tgfp_own+tgfp_rnt gen tgeo_ct_ET=tgei_ct*(tgfp_ct>tgei_ct)+tgfp_ct*(tgfp_cttgsoai_ct)+tgp_fica_ct*(tgp_fica_cttghi_mcare_ct)+ficaexss*(ficaexssmcareexfica)+tgp_smi_ct*(tgp_smi_ct