BookmarkSubscribeRSS Feed
ernie86
Calcite | Level 5

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
2 REPLIES 2
Reeza
Super User

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.);

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1168 views
  • 0 likes
  • 3 in conversation