Stata 来自年和月函数的无意义日期

Stata 来自年和月函数的无意义日期,stata,Stata,我有一个出生时间变量: birthtime 1976m2 1979m8 我运行了以下命令: gen birthyear=year(birthtime) gen birthmonth=month(birthtime) 然而,结果是胡说八道 年和月功能是否不适用于此格式 如何从出生时间变量中检索年份和月份?您需要研究Stata的: 此外: 你需要学习Stata的: 此外: 我发现下面的方法可以做到这一点 gen int temp = dofm(birthtime) gen int birthy

我有一个
出生时间
变量:

birthtime 
1976m2
1979m8
我运行了以下命令:

gen birthyear=year(birthtime)
gen birthmonth=month(birthtime)
然而,结果是胡说八道

功能是否不适用于此格式

如何从
出生时间
变量中检索年份和月份?

您需要研究Stata的:

此外:

你需要学习Stata的:

此外:


我发现下面的方法可以做到这一点

gen int temp = dofm(birthtime)
gen int birthyear = year(temp)
gen byte birthmonth = month(temp)
结果是

birthyear birthmonth
1976         2
1979         8

我发现下面的方法可以做到这一点

gen int temp = dofm(birthtime)
gen int birthyear = year(temp)
gen byte birthmonth = month(temp)
结果是

birthyear birthmonth
1976         2
1979         8