- .di "system date:" c(current_date)
- .di "system date:" "$S_DATE"
- .di %td_CY-N-D date("`c(current_date)'","DMY") // "` '" are not necessary
- .di %td_CY-N-D date("$S_DATE","DMY")
- .di "system year: " year(date(c(current_date),"DMY") // w/o `' around c(current_date)
- .di "system month: " month(date(c(current_date),"DMY"))
- .di "system day:" day(date(c(current_date),"DMY"))
- .di "system year: " year(date("$S_DATE","DMY"))
- .di "system month: " month(date("$S_DATE","DMY"))
- .di "system day:" day(date("$S_DATE","DMY"))
- more examples:
- Works ('local' with '=')
- local dd=day(date(c(current_date),"DMY"))
- local mm=month(date(c(current_date),"DMY"))
- local yy=year(date(c(current_date),"DMY"))
- log using "output_`yy'_`mm'_`dd'.log", replace
- log close
- Doesn't work ('local' without '=')
- local dd day(date(c(current_date),"DMY"))
- local mm=month(date(c(current_date),"DMY"))
- local yy=year(date(c(current_date),"DMY"))
- log using "output_`yy'_`mm'_`dd'.log", replace
- log close // invalid 'DMY' r(198)
- Works ('global' with '=')
- global dd=day(date(c(current_date),"DMY"))
- global mm=month(date(c(current_date),"DMY"))
- global yy=year(date(c(current_date),"DMY"))
- log using "output $yy-$mm-$dd.log", replace
- log close
Disclaimer: This blog site is intended solely for sharing of information. Comments are warmly welcome, but I make no warranties regarding the quality, content, completeness, suitability, adequacy, sequence, or accuracy of the information.
Thursday, September 01, 2016
Stata: display system date
Stata: display system date
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment