Hello Statalisters,

I want to merge two datasets using two string identifiers i.e. name of state and name of sub-region. However, the using dataset correctly reports two states whereas in the master file, the two states are reported as one (information from before the split of the state into two). The only way to get a correct merge is by re-identifying the state name in master dataset using the names of the sub-regions. However it is very arduous and requires a lot of man hours in the way I am currently doing

Code:
 use "$dropbox/masterfile.dta", clear

replace st_name = "Telangana" if subreg == "A" | subreg == "B" | subreg == "C" | | subreg == "D" | | subreg == "E" \\ This continues for another 110 string names which have to manually copied
Is there anyway I could rename the state names en masse by using a loop? I cannot use a fuzzy merge because there are many sub-regions across multiple states with the same name.

Lori


Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str17 st_name str28 ac_name
"andhra pradesh" "Achanta"           
"andhra pradesh" "Addanki"           
"andhra pradesh" "Adoni"             
"andhra pradesh" "Allagadda"         
"andhra pradesh" "Alur"              
"andhra pradesh" "Amadalavalasa"     
"andhra pradesh" "Amalapuram"        
"andhra pradesh" "Anakapalle"        
"andhra pradesh" "Anantapur Urban"   
"andhra pradesh" "Anaparthy"         
"andhra pradesh" "Araku Valley"      
"andhra pradesh" "Atmakur"           
"andhra pradesh" "Avanigadda"        
"andhra pradesh" "Badvel"            
"andhra pradesh" "Banaganapalle"     
"andhra pradesh" "Bapatla"           
       
end