如何使用此格式09sep1943 00:00:00
从Stata变量生成一年并将其存储为%tc
组件?
答案 0 :(得分:4)
这是充分记录的。请参阅help datetime
并使用yofd(dofc())
。
. clear
. set obs 1
number of observations (_N) was 0, now 1
. gen double datetime = clock("09sep1943 00:00:00", "DMY hms")
. format datetime %tc
. gen year = yofd(dofc(datetime))
. l
+---------------------------+
| datetime year |
|---------------------------|
1. | 09sep1943 00:00:00 1943 |
+---------------------------+