Fluorite | Level 6

## Repace Empty Dates with hardcore date

i have below table with dates

 3 1 3/1/2017 3/1/2017 3 2 3/2/2017 3/2/2017 3 3 3/3/2017 3 4 3/4/2017 3 5 3/5/2017 3/5/2017 3 6 3/6/2017

i want to replace the empty dates with hardcore constant date as '31DEC9999'd

Anyone will help me out there

1 ACCEPTED SOLUTION

Accepted Solutions
Diamond | Level 26

## Re: Repace Empty Dates with hardcore date

``if missing(date2) then date2='31DEC9999'd;``
--
Paige Miller
5 REPLIES 5
Diamond | Level 26

## Re: Repace Empty Dates with hardcore date

``if missing(date2) then date2='31DEC9999'd;``
--
Paige Miller
Barite | Level 11

## Re: Repace Empty Dates with hardcore date

Hi,

I think a good hardcore date could be 27th of March 2021 😉

`if missing(date2) then date2='27MAR2021'd;`

But it could be difficult to justify in clinical trials.

If it's hardcode that you mean then please refer to @PaigeMiller 's answer.

________________________

- Cheers -

Super User

## Re: Repace Empty Dates with hardcore date

Use the COALESCE function:

``````data have;
input date yymmdd10.;
format date yymmdd10.;
datalines;
2020-08-12
.
;

data want;
set have;
date = coalesce(date,'31dec9999'd);
run;``````
Super User

## Re: Repace Empty Dates with hardcore date

If the purpose of showing a date of 31DEC9999 is to indicate "missing date" then leave it alone.

What is the complete reason for using a valid date instead of leaving them missing?

You can't model anything with that value, graphs are problematic and statistics like just counting the number of valid dates in your data impossible.

Super User

## Re: Repace Empty Dates with hardcore date

Note that if this is to create an artificial "end" date that lies in a far future, SAS functions do not need that if you need to calculate a "real end":

``````data test;
end_date = .;
real_end_date = min(today(),end_date);
format end_date real_end_date yymmdd10.;
run;``````
Discussion stats
• 5 replies
• 618 views
• 1 like
• 5 in conversation