本文介绍了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)

我试过了

rPOSIX <- as.POSIXct(sas,origin='1960-01-01')

here 所述,但这是错误的.我无法访问 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.

推荐答案

作为我之前的评论,这是一个工作示例,由于特定的 SAS 设置,origin 参数设置为这样,它将原始日期设置为 1960-01-01here资料:

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 日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 22:46