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
Fisher-type test for unit rootHi, I run a panel model using PCSE. Before that, I want to check for stationarity. My panel data is …
Marginal effect and its CI using ivreghdfeHi, I am estimating a two-way fixed effect IV regression with an interactive variable as a predicto…
issue of number of instruments in xtdpdsysHello everyone. I have an unbalanced panel for 105 countries with 15 years time period. have run the…
distance between two addresses (with latitude and longitude)Dear all, I ask this question for someone else (here in Chinese), The data is Code: * Example gener…
Not Stata Format When Merging FilesHello, I am relatively new to Stata and I am trying to merge two datasets. During this process, I ke…
Subscribe to:
Post Comments (Atom)
0 Response to A For Loop problem
Post a Comment