BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Babloo
Rhodochrosite | Level 12

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
1 ACCEPTED SOLUTION

Accepted Solutions
Peter_C
Rhodochrosite | Level 12
The only solution I could imagine to display such a date as 0001-01-01 needs a user defined FORMAT , INFORMAT
Keep the coding meaningful with
StoredValue = input( '0001-01-01', db0date. ) ;
Format storedValue db0date10. ;

Create these formats with
PROC format library= work ;
Value db0date .D = '0001-01-01'
Other = [ yymmddd10. ]
;
InValue db0date '0001-01-01' = .D
Other = [ yymmdd. ]
;
Run;

The policy I recommend is to store known artificial dates as a special missing value ( .D in my example above)

View solution in original post

9 REPLIES 9
Jagadishkatam
Amethyst | Level 16

 

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

 

 

 

Thanks,
Jag
kevinjoseph
Calcite | Level 5

data caperfy11mo01_07;

set caper.caperfy11mo01_12;

where ('08/31/2010'd < encdate1 < '03/01/2011'd);

run;

Babloo
Rhodochrosite | Level 12

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?

Jagadishkatam
Amethyst | Level 16

likely there is no such year as 0001 so it is interpreting as 2001

Thanks,
Jag
ballardw
Super User

@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.

 

 

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Peter_C
Rhodochrosite | Level 12
The only solution I could imagine to display such a date as 0001-01-01 needs a user defined FORMAT , INFORMAT
Keep the coding meaningful with
StoredValue = input( '0001-01-01', db0date. ) ;
Format storedValue db0date10. ;

Create these formats with
PROC format library= work ;
Value db0date .D = '0001-01-01'
Other = [ yymmddd10. ]
;
InValue db0date '0001-01-01' = .D
Other = [ yymmdd. ]
;
Run;

The policy I recommend is to store known artificial dates as a special missing value ( .D in my example above)

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 3369 views
  • 3 likes
  • 7 in conversation