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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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