Saturday, March 6, 2021

How to locate the observations with string IDs sharing some substrings?

For example, I want to change the values of observations for the variable "execution_location" including "Suffolk" to "Suffolk". How can I do it globally? Many thanks! The following is the sample data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str57 execution_location
"'sundry places of the realm'"           
"Aldham Common, Nr Hadleigh, Suffolk"   
"Althone"                                
"Armagh"                                 
"Armagh"                                 
"Armagh"                                 
"Ashford, Kent"                          
"Ashford, Kent"                          
"Askeaton"                               
"At Sea"                                 
"At Sea"                                 
"Athlone"                                
"Ballipodare"                            
"Ballyshannon"                           
"Ballyshannon"                           
"Banbury, Oxfordshire"                   
"Beccles, Suffolk"                       
"Beccles, Suffolk"                       
"Beccles, Suffolk"                       
"'The Sand-pits', Nr Newbury, Berkshire"
"'The Sand-pits', Nr Newbury, Berkshire"
"'The Sand-pits', Nr Newbury, Berkshire"
"Bohemia"                                
"Bohemia"                                
"Bohemia"                                
"Boughton, Cheshire"                     
"Boyle"                                  
"Boyle"                                  
"Boyle"                                  
"Bradford, Wiltshire"                    
"Braintree, Essex"                       
"Brentford"                              
"Brentford, Middlesex"                   
"Brentford, Middlesex"                   
"Brentford, Middlesex"                   
"Brentford, Middlesex"                   
"Brentford, Middlesex"                   
"Brentford, Middlesex"                   
"Brentwood, Essex"                       
"Bridewell"                              
"Bristol"                                
"Bristol"                                
"Bristol"                                
"Bristol, Gloucestershire/Somerset"      
"Bristol, Gloucestershire/Somerset"      
"Bury St Edmunds"                        
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Bury St Edmunds, Suffolk"               
"Calais"                                 
"Calais"                                 
"Calais"                                 
"Camberwell"                             
"Camberwell"                             
"Camberwell"                             
"Cambridge, Cambridgeshire"              
"Canterbury"                             
"Canterbury"                             
"Canterbury"                             
"Canterbury"                             
"Canterbury"                             
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
"Canterbury, Kent"                       
end

No comments:

Post a Comment