Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73296

Loop to append files using two macros

$
0
0
Hi,

I'm appending separate country files in to one (US_1.dta, US_2.dta.........GB_1.dta,GB_2.dta). All of the files are stored in the same folder.

The code I'm using currently to do this is .

Code:
use US_1.dta
 
 forvalues  i = 2 / 5 {
    append using US_part`i'
    
}
  
 save US.dta
However, the list of countries has now grown unmaneagable with 1000 files produced in the folder. Can I create a loop that first searches first for a countryname (US, GB, FR etc) " `i' " and then a numbering structure (_1,_2..._5) " `j' " ?

Thanks


Ciaran

Viewing all articles
Browse latest Browse all 73296

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>