I have a directory which contains 731 .csv files. I would like to convert all of them to .dta before appending all the data. This is the code I have so far:
local csv_directory "C:\Users\Spenc\Desktop\India\India2"
mkdir "`csv_directory'/stata"
clear
local myfilelist : dir "`csv_directory'" files "*.csv"
foreach file of local myfilelist {
import delimited "`file'", clear delim(",") bindquote(strict) maxquotedrows(0)
local outfile = subinstr("`file'",".csv","",.)
save "`C:\Users\Spenc\Desktop\India\India2`outfile' ", replace
}
My very first CSV file gets the error "file `C:\Users\Spenc\Desktop\India\India2indiamart_24-parganas.dta could not be opened." It shouldn't reading it as a dta, but csv.
Does anyone see what I be doing wrong here? Much Appreciation.
-Tyler
local csv_directory "C:\Users\Spenc\Desktop\India\India2"
mkdir "`csv_directory'/stata"
clear
local myfilelist : dir "`csv_directory'" files "*.csv"
foreach file of local myfilelist {
import delimited "`file'", clear delim(",") bindquote(strict) maxquotedrows(0)
local outfile = subinstr("`file'",".csv","",.)
save "`C:\Users\Spenc\Desktop\India\India2`outfile' ", replace
}
My very first CSV file gets the error "file `C:\Users\Spenc\Desktop\India\India2indiamart_24-parganas.dta could not be opened." It shouldn't reading it as a dta, but csv.
Does anyone see what I be doing wrong here? Much Appreciation.
-Tyler
Comment