Hello all,
I am trying to use a local macro using c(current_date) that returns the last numeric day of the prior month for use in file directories/names (e.g.
returns
).
For last numeric day of the prior month I have:
This is the value I was expecting. But when I try to make this into a local macro I get an error:
The same error is happening for a macro for the numeric value of the prior month:
but
Obviously a syntax error on my part, but I cannot determine how to fix it from help datetime. Or if there is a more elegant/efficient way, including ssc or other user programs, I'd appreciate the guidance.
Thanks in advance,
Jim
I am trying to use a local macro using c(current_date) that returns the last numeric day of the prior month for use in file directories/names (e.g.
Code:
C:/path/`year'_`lastmonthno'_`lastdayno'_filename
Code:
C:/path/2018_10_31_filename
For last numeric day of the prior month I have:
Code:
. di %td_D dofm(mofd(td(`c(current_date)')))-1 31
Code:
. local lastday= %td_D dofm(mofd(td(`c(current_date)')))-1 %td_D invalid name r(198);
Code:
. di %td_N dofm(mofd(td(`c(current_date)')))-1 10
Code:
. local lastmonthno = %td_N dofm(mofd(td(`c(current_date)')))-1 %td_N invalid name r(198);
Thanks in advance,
Jim
Comment