SAS importing dates from excel

↘锁芯ラ 提交于 2020-01-30 03:27:48

问题


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

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


回答1:


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;


来源:https://stackoverflow.com/questions/54370636/sas-importing-dates-from-excel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!