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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1265 views
  • 1 like
  • 5 in conversation