sas7bdat日期格式为R日期格式 [英] sas7bdat date format to R date format
本文介绍了sas7bdat日期格式为R日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 sas7bdat
软件包加载了一个sas7bdat文件,但日期被转换为这样的数字:
I loaded a sas7bdat file using the sas7bdat
package, but the dates are converted to a num like this:
sas <- c(16922, 17045, 17014, 16983)
尝试
I tried
rPOSIX <- as.POSIXct(sas,origin='1960-01-01')
如上所述这里,但它是错误的。我无法访问SAS,但日期应在2006年左右。
as mentioned here but it's wrong. I don't have access to SAS but the dates should be around the year 2006.
推荐答案
作为我之前的评论,这里是一个工作示例,其中 origin
参数是由于特定的SAS设置而设置的,该设置将起始日期设置为 1960-01-01
,此处信息:
As my previous comment, here is a working example, where the origin
argument is set like that because of a specific SAS setting, which sets the origin date to 1960-01-01
, here informations:
as.Date(sas, origin = "1960-01-01")
[1] "2006-05-01" "2006-09-01" "2006-08-01" "2006-07-01"
这篇关于sas7bdat日期格式为R日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文