Hi,
I am trying to find a way to convert a date into a like for like character string to I can merge in data using the date as a variable.
For example
Reference | Date | date2 |
893746 | 31MAR2002:00:00:00.000 | Mar-02 |
Where date2 is the datepart(date) formatted using monyy5.
I would like to make a variable date3 that is a character replica of date2 as I don't want to deal with days in the merge.
Does anyone know an easy way to do this?
Thanks.
A reasonable way:
length date3 $ 3;
date3 = put(date2, monyy5.);
Because of the LENGTH statement, there is only room to store the first 3 characters.
OK, then give DATE3 a length of $5 instead of $3.
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.