I want to save the results of my Stata forvalues
loop into individual files. One component of the filename should be the value j
assigned to the macro within a forvalues
loop.
Apparently my code leads to an instruction always to save with 1995
. As such, I get messages telling me that this file already exists.
I am using the following code:
local j = 1995
forvalues `j'= 1995 / 2012 {
clear
use "/Users/carl/Desktop/STATA/Neustart/eventdates.dta", clear
keep if eventyear == `j'
sort acq_cusip eventdate
compress
save "/Users/carl/Desktop/STATA/Neustart/eventdates_`j'.dta"
}
Does anyone have an answer to that?