Appreciate if someone of you guide me to resolve the error? INDDBG and INDDEI is a date fields and if it is missing I need to replace the missing values with '0001-01-01'd and '9999-12-31'd
106 (case when INDDBG=. then '0001-01-01'd
ERROR: Invalid date/time/datetime constant '0001-01-01'd.
107 else INDDBG
108 end) as INDDBG length = 8
109 format = YYMMDD10.,
110 (case when INDDEI=. then '9999-12-31'd
ERROR: Invalid date/time/datetime constant '9999-12-31'd.
111 else INDDEI
You already know the correct format for a date literal, see here: https://communities.sas.com/t5/SAS-Programming/Extracting-date-from-day-month-year/td-p/497684
please try
case when INDDBG=. then input('0001-01-01',yymmdd10.)
else INDDBG
end) as INDDBG length = 8
format = YYMMDD10.,
(case when INDDEI=. then input('9999-12-31',yymmdd10.)
else INDDEI
data caperfy11mo01_07;
set caper.caperfy11mo01_12;
where ('08/31/2010'd < encdate1 < '03/01/2011'd);
run;
I tried your code, but the value for INDDBG appearing as '2001-01-01' instead of '0001-01-01'. What might be the likely cause for this issue?
likely there is no such year as 0001 so it is interpreting as 2001
@Babloo wrote:
I tried your code, but the value for INDDBG appearing as '2001-01-01' instead of '0001-01-01'. What might be the likely cause for this issue?
The earliest YEAR that SAS supports is 1581, the year England accepted the Gregorian calendar reforms IIRC. So anything referencing a year prior to that is going to have problems.
What data do you have that is using years prior to 1581?
Prior to that many more countries than current had somewhat different calendars for a number of historical reasons.
So anything referencing a year prior to that
is going to have problems.
will not work.
But yes, it's hard to imagine anyone having data (other than perhaps from astronomy) that needs dates earlier than 1583.
Databases often use 0001-01-01 as "default date" when a date column has a "not null" constraint.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: