[英]Converting SAS date to month indexing system
How can I convert the month and year of a date to match a variable named by a month indexing system used in a study where January 1986 is month 1? 如何转换日期的月份和年份以匹配由1986年1月为第1个月的研究中使用的月份索引系统命名的变量? I need to create a variable that calculates the difference between the current month and Jan 1986 but am not sure how to get started.
我需要创建一个变量来计算当月与1986年1月之间的差额,但不确定如何开始。 My dates are currently in YYYYMMDD format.
我的日期目前为YYYYMMDD格式。
The intck
function tells you how many intervals of something occur between two dates. intck
函数告诉您两个日期之间发生间隔的时间间隔是多少。
monthnum = intck('month','01JAN1986'd, surveydate);
If you only have month/year, you can use the mdy
function to construct a date. 如果只有月/年,则可以使用
mdy
函数构造日期。
dtvar = mdy(monthvar,1,yearvar);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.