Hi,
I'm trying to automatically create a global macro in my do files of the current date, that I can append to log file names etc.
In format DDNNYYYY. So today would be 02112018.
I was hoping to be able to do this in one or two lines with macro functions.
But the closest I can get is as follows..which involves creating a variable.
Any suggestions for a better way?
sysuse auto
gen date_current_temp = date("`c(current_date)'","DMY",2000) in 1
format date_current_temp %tdDDNNCCYY
global date = string(date_current_temp,"%tdDDNNCCYY") in 1
drop date_current_temp
di "$date"
Regards,
Andrew
I'm trying to automatically create a global macro in my do files of the current date, that I can append to log file names etc.
In format DDNNYYYY. So today would be 02112018.
I was hoping to be able to do this in one or two lines with macro functions.
But the closest I can get is as follows..which involves creating a variable.
Any suggestions for a better way?
sysuse auto
gen date_current_temp = date("`c(current_date)'","DMY",2000) in 1
format date_current_temp %tdDDNNCCYY
global date = string(date_current_temp,"%tdDDNNCCYY") in 1
drop date_current_temp
di "$date"
Regards,
Andrew
Comment