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
Flag repetitionsSuppose I have a dataset containing two variables X and Y. Without resorting the data, I would like …
Record linkage with quantitative variablesI have two datasets describing the same 80 schools. Some variables are similar -- for example, both…
Another way of measuring period effect on investment risk tolerance?I'm doing a research about the relationship between investment risk tolerance and demographic factor…
Download and unzip file with StataHi, I was wondering if it is possible to download a *.zip file from a website, unzip the *.csv file…
Arellano-Bond in Stata: xtabond, xtabond2, or xtdpdgmm if I'm including an interaction? And can I enter differenced focal variables?Hi, I'm trying to run a dynamic panel model on a panel dataset in Stata 14.1. I have a couple questi…
Subscribe to:
Post Comments (Atom)
0 Response to A For Loop problem
Post a Comment