Pages

Wednesday, August 7, 2013

Widgets

Convert Excel Date to SAS Date

When we import excel files into a SAS dataset then the conversion of date/time from excel to SAS becomes messy. 1 January 1960 is Day 0 in SAS while Day 1 in Excel. Below formulas will help to convert the date/time from Excel to SAS

  • SAS_date = Excel_date - 21916;
  • SAS_time = Excel_time * 86400;
  • SAS_date_time = (Excel_date_time - 21916) * 86400;

Excel has two different datetime "systems" and the default differs depending on the platform. The above formulas assume Excel is using the 1900 date system. If Excel is using the 1904 Date System, use 20454 in the above formulas instead of 21916.

No comments:

Post a Comment