Hello All,
I am trying to append 86 xls files. Each csv file is named by numbers, e.g., 1.xls, 2xls, 3.xls, etc.. All files have the same variable lists.
I use the following code to append the files:
However, I have noticed that my code generates double observations and I really don't understand why..
To append another set of files (csv files), I have used a different code as the names of the files were very different, and again, the code generated double observations.
I would be very grateful if you could help me understand where the issue is.
I am trying to append 86 xls files. Each csv file is named by numbers, e.g., 1.xls, 2xls, 3.xls, etc.. All files have the same variable lists.
I use the following code to append the files:
Code:
import excel "$Announcements\1.xls", sheet("Screening") cellrange(A8:O10008) firstrow clear
gen file=1
save "$Final_data\Announcements_merged", replace
forval i=2/86{
import excel "$Announcements/`i'.xls", sheet("Screening") cellrange(A8:O10008) firstrow clear
append using "$Final_data\Announcements_merged"
replace file=`i' if missing(file)
save "$Final_data\Announcements_merged", replace
}
use "$Final_data\Announcements_merged", clear
sort file
To append another set of files (csv files), I have used a different code as the names of the files were very different, and again, the code generated double observations.
Code:
tempfile temp1 temp2 temp3 temp4 temp5 temp6 temp7 temp8 temp9
import delimited "$SSL\airline.csv", clear
gen domain = "airline"
save "`temp1'", replace
import delimited "$SSL\auto.csv", clear
gen domain = "auto"
save "`temp2'", replace
append using "`temp1'" "`temp2'", force
save "`temp1'", replace
import delimited "$SSL\beverages.csv", clear
gen domain = "beverages"
save "`temp2'", replace
append using "`temp1'" "`temp2'", force
save "`temp1'", replace
save "$Final_data/SSL_merged", replace
I would be very grateful if you could help me understand where the issue is.

Comment