Im trying to reformat column DateA to column DateB. The tricky part is there are characters in the column, ie "Not Applicable", so SAS is reading the whole column as character. I tried many different ways but they don't seem like working. So I wonder if it is possible to reformat date if there are characters in the column.
Group | DateA | DateB |
Group A | 4/1/2016 | 04/01/2016 |
Group B | 5/2/2016 | 05/02/2016 |
Group C | 8/1/2016 | 08/01/2016 |
Group D | 10/8/2016 | 10/08/2016 |
Group E | Not Applicable | Not Applicable |
Group F | 5/1/2016 | 05/01/2016 |
Group G | Not Applicable | Not Applicable |
Group H | 6/9/2016 | 06/09/2016 |
Group I | Not Applicable | Not Applicable |
Group J | 9/1/2016 | 09/01/2016 |
Group K | 1/10/2016 | 01/10/2016 |
You can conditionally execute your code. This could be made a one-liner if you use ifn/ifc and/or if you apply ? to your input format, but I'll let you work those out 🙂
if dateb='Not Applicable' then dateb_converted=.;
else dateb=input(dateb, mmddyy10.);
As Reeza has pointed out, conversion is pretty simple, and just drop the "Not" values. However I would question firstly what those dates reflect, is it really MMDDYY, or DDMMYY? Secondly why dates in DateA do not have the padding zero. Looks a bit fishey if you ask me, I would check the source data.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.