use "..\Revere_quarterly.dta", clear
replace s_cusip = substr(s_cusip,1,6)
replace c_cusip = substr(c_cusip,1,6)

rename s_cusip cusip
merge m:1 cusip using "..\Data\GICS\cusip6_gics.dta", keepusing(gsector)
drop if _merge==2
drop _merge
rename (cusip gsector) (s_cusip s_gsector)

rename c_cusip cusip
merge m:1 cusip using "..\Data\GICS\cusip6_gics.dta", keepusing(gsector)
drop if _merge==2
drop _merge
rename (cusip gsector) (c_cusip c_gsector)
 

order datacqtr s_name s_ticker s_cusip s_gsector c_name c_ticker c_cusip c_gsector 
sort datacqtr s_cusip c_cusip s_gsector c_gsector
duplicates drop datacqtr s_cusip c_cusip, force
export delimited using "revere.csv",  replace
