I want to save a number of files within a loop using the local macro as filename, for example
In this case, I want to save ten files namned "1.dta", "2.dta", ..., "10.dta" respectively in the directory "C:\Users\matoh389\Downloads". However, what the above code does is to save one file (probably overwriting it nine times) namned "Downloads`i'.dta" in the directory "C:\Users\matoh389". What am I doing wrong?
I am using the Windows version of Stata 14.0, current update level: 10 Jun 2015.
Code:
forvalues i = 1/10 { clear all insobs 10 gen test = `i' save "C:\Users\matoh389\Downloads\`i'", replace }
I am using the Windows version of Stata 14.0, current update level: 10 Jun 2015.
Comment