Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Problem in appending data files.

From   Amir Kasaeian <>
To   "" <>
Subject   st: Problem in appending data files.
Date   Tue, 6 Nov 2012 05:46:25 -0800 (PST)

Dear all,
Good day!
I have a problem in appending my data files.
I wrote a loop but there is little problem that I don't know how to resolve it.
Your help will be appreciated.
I use stata MP 11.
The problem is that I have 30 files in a folder named S0 through S1. I want to have a final file named for example "Total" including a new variable as an indicator for observations of each of 30 separate files.
I wrote my file as :

forvalues i= 0/29 {
append using "C:\Total85\S`i'.dta" , 
gen Province=`i'
save "C:\Total85\Total.dta", replace

but the code stops at the first step alarming:

. do "C:\Users\AK\AppData\Local\Temp\STD00000000.tmp"

. forvalues i= 0/29 {
  2. append using "C:\Total85\S`i'.dta" , 
  3. gen Province=`i'
  4. save "C:\Total85\Total.dta", replace
  5. } 
file C:\Total85\Total.dta saved
Province already defined

end of do-file


The Total file just includes observation from the S0.
Would you please help me to modify my codes?
Bunch of thanks,

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index