Hi ,
I am wondering How to loop on all CSV files in several folders and create a separate dta files .
for example :
Sample for input files :
C:\folder\country1\year1\filename1.csv
C:\folder\country1\year1\filename2.csv
C:\folder\country1\year1\filename3.csv
C:\folder\country2\year2\filename1.csv
C:\folder\country2\year2\filename2.csv
C:\folder\country2\year2\filename3.csv
Sample for output files :
C:\folder\country1\year1\filename1.dta
C:\folder\country1\year1\filename2.dta
C:\folder\country1\year1\filename3.dta
C:\folder\country2\year2\filename1.dta
C:\folder\country2\year2\filename2.dta
C:\folder\country2\year2\filename3.dta
foreach country in country1 country2 country3 { ;
foreach year in year1 year2 year3 { ;
foreach file in "filename*.csv" { ;
cd "C:\folder\`country'\`year'" ;
import delimited using "filename*.csv", case(preserve) clear ;
gen file ;
};
};
} ;
Related Posts with How to loop on all CSV files in several folders and create a separate dta files
flat log likelihood encountered, cannot find uphill directionI am working with a time series data, i try to forecast next day volatility with EGARCH (1,1) I got …
Difference-in-difference on matched data with binary outcome variableDear Statalisters, I have a balanced data with three waves. I want to measure the impact of partici…
Difference-in-difference on matched data with binary outcome variableI have a balanced data with three waves. I want to measure the impact of participation on a binary o…
data merge: r(459);Hi, I have two panel data-set and what to merge the two data set. I use the following code but I rec…
Bootstrapping versus robust VCE option in xtpoission to deal with overdispersionHi everyone, Does the bootstrapping option in xtpoission deal with overdispersion, or is vce(robust…
Subscribe to:
Post Comments (Atom)
0 Response to How to loop on all CSV files in several folders and create a separate dta files
Post a Comment