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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.