Oracle在SAS中以J(Julian)格式更新

Oracle在SAS中以J(Julian)格式更新,oracle,sas,to-date,julian-date,Oracle,Sas,To Date,Julian Date,你知道有人如何将甲骨文中代表朱利安日期的数字转换成SAS吗?我已经在SAS中有一个表,它有time\U key列。在Oracle中,转换为_datetime_键“j”,其中j代表朱利安。您知道如何在SAS中执行此操作吗 SAS表格示例: TIME_KEY 2456658 2456689 预期产出: TIME_KEY_DATE 31DEC2013 31JAN2014 我对甲骨文的朱利安日期格式一无所知,但它似乎只是从某个“第0天”开始的几天,就像在SAS中一样。SAS中的第0天是

你知道有人如何将甲骨文中代表朱利安日期的数字转换成SAS吗?我已经在SAS中有一个表,它有time\U key列。在Oracle中,转换为_datetime_键“j”,其中j代表朱利安。您知道如何在SAS中执行此操作吗

SAS表格示例:

TIME_KEY
 2456658
 2456689
预期产出:

TIME_KEY_DATE
 31DEC2013   
 31JAN2014

我对甲骨文的朱利安日期格式一无所知,但它似乎只是从某个“第0天”开始的几天,就像在SAS中一样。SAS中的第0天是1960年1月1日,因此我们只需要计算Oracle系统(其中2013年12月31日为第2456658天)和SAS系统(其中2013年12月31日为22280天)之间的偏移量:

data dates;
  time_key = 24566658; output;
  time_key = 24566689; output;
run;

* Calculate the offset, given 24566658 is 31-Dec-2013;
data _null_;
  call symput("offset", 24566658 - "31DEC2013"d);
run;

%put Offset from SAS dates to Oracle dates is &offset days;

data converted;
  set dates;
  * Adjust the Oracle date values by subtracting the calculated offset;
  sas_time_key_numeric = time_key - &offset;
  sas_time_key = put(time_key - &offset, date9.);
  put time_key= sas_time_key_numeric= sas_time_key=;
run;
输出为:

10   %put Offset from SAS dates to Oracle dates is &offset days;
Offset from SAS dates to Oracle dates is     24546935 days
11
12   data converted;
13     set dates;
14     sas_time_key_numeric = time_key - &offset;
15     sas_time_key = put(time_key - &offset, date9.);
16     put time_key= sas_time_key_numeric= sas_time_key=;
17   run;

time_key=24566658 sas_time_key_numeric=19723 sas_time_key=31DEC2013
time_key=24566689 sas_time_key_numeric=19754 sas_time_key=31JAN2014
这给出了正确的转换

所以这个神奇的数字是24546935;从Oracle日期中减去该值以获得相应的SAS日期值,然后应用所需的日期格式