I have several .csv data files that I want to import and save using a for loop.
The file names have a pattern, namely, scd1011, scd1112, scd1213, scd1314,...,scd1516
I am thinking of the following code, but cannot get the result
1. forvalues i =10(1)15{
cd "$rawdata"
insheet using "scd`i'`i+1'.csv", clear
cd "$workdata"
save "scd`i'`i+1'.dta",replace
}
2. forvalues i =10(1)15{
scalar j=i+1
cd "$rawdata"
insheet using "scd`i'`j'.csv", clear
cd "$workdata"
save "scd`i'`j'.dta",replace
}
Is there any solution to this?
Related Posts with A For Loop problem
Can i pick the Model with lower AIC but higher BIC?Good day Everyone, I was comparing two models Model2 has a lower AIC but a higher BIC. can i pick m…
Quantile regression (QR) for panel dataDear all, i hope you are doing good i'm trying to work on a non linear relationship. does quantile…
probleme to perform ado functionDears, i am a new one on this forum and on stata, thank you for your help my question is : I want t…
Controlling for year when appending two datasetsHello, One newbie question but I'm stuck on this basic task. I'm pooling two datasets from two diff…
probleme to perform ado functionDears, i am a new one on this forum and on stata, thank you for your help my question is : I want t…
Subscribe to:
Post Comments (Atom)
0 Response to A For Loop problem
Post a Comment