I want to generate a variable with lagged year depending on the year stored in the "$S_DATE"
macro. I have stored the year in a macro named date
:
. local date substr("$S_DATE",8,.)
. display `date'
2015
And I want to generate the new variable with:
gen start_year =`date'- y_passed
where y_passed
is a variable containing integers from 1 to 10.
However, I get:
. gen start_year = `date' - y_passed
type mismatch
r(109);
I know this happens because the macro stored is a string.
How can I change the value stored in local macro from string to numeric?