I have dates that are messy. The missing values are coded as 99 for month and year.
The rule i want to implement is as follows:
Month missing/day missing/Year = 7/1/Year
Month/day missing/Year = Month/15/Year
Here is the dataset:
DateR |
99/99/2006 |
99/99/2006 |
8/99/2017 |
8/99/2017 |
8/99/2017 |
8/99/2017 |
7/99/2018 |
7/99/2018 |
6/99/2015 |
Thanks!!
Do you have any with just Month missing (assume by "missing" you mean a value of 99 is recorded and that the expected order is MMDDYYYY)?
And including one actual valid date for comparison:
data example; input DateR :$10.; if scan(dater,2)='99' then do; if scan(dater,1)='99' then date=mdy(7,1,input(scan(dater,3),best.)); else date= mdy(input(scan(dater,1),best.),15,input(scan(dater,3),best.)); end; else date= input(dater,mmddyy10.); format date mmddyy10.; datalines; 99/99/2006 99/99/2006 8/99/2017 8/99/2017 8/99/2017 8/99/2017 7/99/2018 7/99/2018 6/99/2015 4/12/2012 ;
Do you have any with just Month missing (assume by "missing" you mean a value of 99 is recorded and that the expected order is MMDDYYYY)?
And including one actual valid date for comparison:
data example; input DateR :$10.; if scan(dater,2)='99' then do; if scan(dater,1)='99' then date=mdy(7,1,input(scan(dater,3),best.)); else date= mdy(input(scan(dater,1),best.),15,input(scan(dater,3),best.)); end; else date= input(dater,mmddyy10.); format date mmddyy10.; datalines; 99/99/2006 99/99/2006 8/99/2017 8/99/2017 8/99/2017 8/99/2017 7/99/2018 7/99/2018 6/99/2015 4/12/2012 ;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: