SAS从excel导入日期 [英] SAS importing dates from excel
问题描述
我有一个使用 proc import 导入的 xlsx 数据集.excel中有一个包含日期值的列,例如:2018-11-30 00:00:00当我将其导入 SAS 时,它会自动将其转换为数字 43434.当我尝试将其转换为日期时:put(col,date9.),我得到:2078-12-01
I have an xlsx dataset that I import using proc import. There is a column in excel that holds date values like: 2018-11-30 00:00:00 When I import it into SAS it automatically converts it into a number 43434. When I try to cast this to a date: put(col,date9.), i get: 2078-12-01
发生了什么?我怎样才能找回正确的日期.我尝试了 mix=yes 选项,但它不适用于 dbms=xlsx.当我做 dbms=excel 时,它没有按预期工作
What is happening? How can I get back the correct date. I tried mixed=yes option but it does not work with dbms=xlsx. When i do dbms=excel, it does not work as expected
推荐答案
有时 SAS 将日期作为原始 Excel 日期导入.我不知道为什么或何时这样做,但我认为这与日期的格式有关.如果发生这种情况,请将日期减去 21916 以将 Excel 日期转换为 SAS 日期.
Sometimes SAS imports the date as a raw Excel date. I don't know exactly why or when it does this, but I think it has something to do with the format of the date. If this happens, subtract the date by 21916 to convert from an Excel date to a SAS date.
data want;
set imported_from_excel;
date = excel_date - 21916;
run;
这篇关于SAS从excel导入日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!