I have a birthdate such as 01SEP60:00:00:00.
Length = 8
Format datetime16.
Informat anydtdtm40.
I want to get the year of this string. I tried birth_year = year(input(birthdate,anydtdte20.)); I did not get any erro but every birth_year came out as missing.
Thank you!
b_y = year(datepart(birthdate));
?
Bart
b_y = year(datepart(birthdate));
?
Bart
So you don't have a DATE (number of days). You have a DATETIME (number of seconds).
The YEAR() function needs a DATE value. You can convert a DATETIME value to a DATE value by using the DATEPART() function.
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.
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.