同理,Stata 还提供了其他时期函数(Date and time functions)用于帮助我们获得其他日期数据对应的数值,这些数值对于开展某些研究而言可能是有用的,这里仅关注常规的时期数据(即“年-月-日”)。 代码语言:javascript 复制 dimdy(12,31,1959)*-1dimdy(1,1,1960)*0dimdy(1,3,1960)*2dimdy(1,20,2020)*21934...
dateofbirth str9 %9s Date of birth reason str15 %15s Reason for visit admit_d str8 %9s Admission date admit_t str17 %17s Admission date and time discharge_d str9 %9s Discharge date discharge_t str14 %14s Discharge date and time --- Sorted by: */ list admit_d dateofbirth /* +...
这里date就是一个长的字符串日期了。接着还是转换+格式化。 更多转换函数和日期格式,可参考Stata相关帮助文件。 References StataDate and time functions帮助文件
*第二步,改变eventtime的显示格式 gen double eventtime_format = eventtime, after(eventtime) format eventtime_format %tc //以时钟型数据显示 *将三列数据进行对比。如下图 format eventtime %20.0f br TIMESTAMP eventtime eventtime_format 这里变量eventtime变量显示的是Stata眼中的真正变量取值(从1960年1...
此外,你还可以使用时间序列分析命令(如tsline、tsset等)来处理和分析时间序列数据。 额外资源 为了更深入地了解Stata处理日期数据的方法,你可以参考以下资源: Stata官方文档:Date and Time Functions 自定义命令datedv的详细实现和用法:链接(提取码:1234) 希望这些解答能帮助你更好地在Stata中处理日期数据!
Stata日期和时间处理指南说明书 in Stata Gabriela Ortiz Applied Econometrician StataCorp LLC 1
Date and time functions Updated Complete suite of functions for manipulating dates and datetimes, including support for business calendars and leap seconds Convert dates and datetimes in string form to numeric form with great flexibility, including support for any order of year, month, day, hour,...
New date and time functions Stata 17 adds a plethora of date and time convenience functions in three main areas: Datetime durations, such as ages Relative dates, such as the next birthday relative to a reference date Datetime components, functions that extract various components from datetime value...
New date and time functions Stata 17 adds a plethora of date and time convenience functions in three main areas: Datetime durations, such as ages Relative dates, such as the next birthday relative to a reference date Datetime components, functions that extract various components from datetime value...
Intro Introduction to functions reference manual Functions by category Functions by name Date and time functions Mathematical functions Matrix functions Programming functions Random-number functions Selecting time-span functions Statistical functions String functions Trigonometric functions Combined author index ...