BookmarkSubscribeRSS Feed
heyyou1
Fluorite | Level 6

The data I am working with has strangely formatted birthdates. For example:

29SEP86:00:00:00
26MAR81:00:00:00
01DEC45:00:00:00

Their birth dates then get plugged into the 

intck("year", birthday, TODAY())

function to find a persons current's age.

 

 

How would I parse the above numbers into correct SAS date-time numbers?

1 REPLY 1
ballardw
Super User

Is that value a character or numeric? It may help to show us the results of Proc contents for that data set if you are not sure.

If the value is character you can read it with a DATE7 informat:

data example;
   x="29SEP86:00:00:00";
   datex = input(x,date7.);
   format datex date9.;
run;

If the value is numeric then it should bea datetime value and you could get the just the date with the DATEPART function:

data example;
   x="29SEP86:00:00:00"dt;
   datex = datepart(x);
   format x datetime16. datex date9.;
run;

 

This is one of the things I typically blame on poor database programmers using some default that treats dates as date time values. If all of the time components are the same, ie 00:00:00 then the is no meaningful time to deal with.

 


@heyyou1 wrote:

The data I am working with has strangely formatted birthdates. For example:

29SEP86:00:00:00
26MAR81:00:00:00
01DEC45:00:00:00

Their birth dates then get plugged into the 

intck("year", birthday, TODAY())

function to find a persons current's age.

 

 

How would I parse the above numbers into correct SAS date-time numbers?


 

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 468 views
  • 1 like
  • 2 in conversation