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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.