2005 invalid name
r(198);
- local i = 2005
- while `i' < 2007{
- local j=`i'+1
- **step 10: match by firm ID**
- *deal with duplicates of IDs (there are a few firms that have same IDs)*
- use m`i'.10.dta, clear
- bysort id`i': keep if _N>1
- save duplicates_ID`i'.dta, replace
- use m`i'.10.dta, clear
- bysort id`i': drop if _N>1
- rename id`i' id
- keep id name`i' legal_person`i' dq`i' provcd`i' city`i' county`i' town`i' street`i' community`i' phone`i' cic`i' holding_status`i' bdat`i' allemployee`i' femalenumber`i' Operating_income`i' Main_business_income`i' total_assets`i' new_product_output`i' sales_revenue`i' export_`i' fixed_assets`i' total_liabilities`i' subsidy_income`i' total_profit`i' industry `i' product1_`i'
- sort id
- save match`i'.1.dta, replace
- use m`j'.10.dta, clear
- bysort id`j': keep if _N>1
- save duplicates_ID`j'.dta, replace
- use m`j'.10.dta, clear
- bysort id`j': drop if _N>1
- rename id`j' id
- keep id name`j' legal_person`j' dq`j' provcd`j' city`j' county`j' town`j' street`j' community`j' phone`j' cic`j' holding_status`j' bdat`j' allemployee`j' femalenumber`j' Operating_income`j' Main_business_income`j' total_assets`j' new_product_output`j' sales_revenue`j' export_`j' fixed_assets`j' total_liabilities`j' subsidy_income`j' total_profit`j' industry `j' product1_`j'
- sort id
- save match`j'.1.dta, replace
- use match`i'.1.dta, clear
- merge id using match`j'.1.dta
- keep if _merge==3
- gen id`i'=id
- rename id id`j'
- drop _merge
- gen match_method_`i'_`j'="ID"
- gen match_status_`i'_`j'="3"
- save matched_by_ID`i'_`j'.dta, replace
- local i = `i' + 1
- }