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.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.