The SAS Output Delivery System and reporting techniques

Date renderring in SAS

Reply
Super Contributor
Posts: 260

Date renderring in SAS

Hi everyone.

We're looking for a great idea to store dates (and display them properly) more ancient than 1582. Currently, I face great difficulties to store such dates as january 1st, 1492 ; not to mention displaying them, or applying SAS date functions on them !

Any hints welcome.
Thanks in advance

Olivier
N/A
Posts: 0

Re: Date renderring in SAS

ignore the problem that has caused SAS to stop at 1582 (the change of the calendar resulted in a "loss" of days) !
I don't think so!
I'm not sure what months were called in earlier calendars, or whether "seasons" or "legal quarter dates" or "religous festivals" would be used to define "the time within a year".

Have you some definition among your "input data" that would clarify what level of definition within an "early-year" you need ?

If only the year number is needed, then don't worry about SAS date standards ~ just use the year as a number.

Hope these ideas prove helpful and the questions lead to a better definition of the shape of your solution.

Merry Christmas,
Peter
Super Contributor
Posts: 260

Re: Date renderring in SAS

Thank you Peter.

I totally agree with what you are saying about discarding days and months, and only considering years -- especially for times when months definitions were not the same as ours.
We will either solve our problem of early dates with storing only years, or re-considering the matter with a "what exactly is your need" approach.

Merry Christmas too.
N/A
Posts: 0

Re: Date renderring in SAS

if you make a decision that "early years" are just the year number, you might want a user format that uses ranges. Here's a demo demonstrating why you might want to avoid using integer years [PRE]
proc format ;
picture older_ds /* handling older dates than SAS */
"1jan1582"d - <0 = [date9.]
0 - 1581 = '1234'( prefix='old~' )
1582 - "31dec9999"d = [date9.]
;
%put >>%sysfunc( putn( 1234, older_ds ))<<;
data demo;
do date = 1581,
"1jan1582"d to "1jan1960"d by 35000,
"1jan1870"d to "1jan1960"d by 7000,
"1jan1950"d to "1jan1960"d by 700,
-5 to 10,
1066, 1284, 1413,
1580 to 1590;
put date date= older_ds. ;
output ;
end;
run; [/PRE]

treating date values zero to 1581 as a year number loses regular SAS dates 1jan60 - 30Apr64 as old~years.

Using a suitable picture modifier multiplier would allow old~years to be placed above or below the valid SAS date number range .

Here's the picture for placing early~years above the valid sas date range with multiplier 1e-7. 10660000000 ( or 1066e7) is displayed as o:yr1066. Old~year date arithmetic is supported by doing the same as the picture "multiplier=" modifier, that is: dividing by 1e7 [PRE]
proc format ;
picture older_ds /* handling older dates than SAS */
1e7 - 1581e7 = '1234'( prefix='o:yr' mult= 1e-7 )
1582e7 -high = '1234'( prefix='2high' mult= 1e-7 )
other = [date9.]
;
run;
data demo;
do date = 1581,
"1jan1582"d to "1jan1960"d by 35000,
"1jan1950"d to "1jan1960"d by 700,
1066e7, 1284e7, 1413e7,
1580e7 to 1584e7 by 1e7,
1e7 to 10000010,
19999996 to 20000004,
2e7 to 1582e7 by (1e7*33)
;
put date date= older_ds. ;
output ;
end;
run; [/PRE]
as you can see, an old~year constant would appear as
1066e7

Given that SAS integers in standard 8byte numerics are precise to 16 or 17 digits, a 4 digit year and 7-zeros suffix are supported "precisely" .

What's the application that wants to use such history ?

Peter
Ask a Question
Discussion stats
  • 3 replies
  • 133 views
  • 0 likes
  • 2 in conversation