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
EgarchHello everyone, I wanted to run a mean equation using OLS with robust s.e.,, like below: reg ir L.…
RDplot IssueHi everyone, It is my first time using rdplot and rdrobust and I am trying to do the following: Co…
No observations error "r2000"Hello, I searched on various forums regarding the "no observations r2000 error" but can't seem to so…
Fixed effects month dummies: How to combine them all in one variable?Dear community, For an assignment: "include now in the regression fixed effects for borrowers’ coun…
Event study graph for multiple coefficientsI have an individual-level dataset where each row corresponds to a birth, with information on exact …
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