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

i have below table with dates

 

313/1/20173/1/2017
323/2/20173/2/2017
333/3/2017 
343/4/2017 
353/5/20173/5/2017
363/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
PaigeMiller
Diamond | Level 26
if missing(date2) then date2='31DEC9999'd;
--
Paige Miller

View solution in original post

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

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 -

Kurt_Bremser
Super User

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;
ballardw
Super User

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.

 

 

 

Kurt_Bremser
Super User

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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 811 views
  • 1 like
  • 5 in conversation