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
if missing(date2) then date2='31DEC9999'd;
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 -
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;
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.
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;
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.
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.
Ready to level-up your skills? Choose your own adventure.