Hi all,
I am trying to concatenate three date variables into a single numeric date value. The separate variables are day, month, and year. I am trying to concatenate the three variables into a single numeric date value and am struggling. I am wondering if I am using the wrong informat or if I am nesting my functions inappropriately. Here is my code:
DATA WORK.Want;
SET Work.Have; BirthDt = INPUT(CAT(BirthMonth, BirthDay, BirthYear), ANYDTDTE9.); RUN;
Thank you for the help!
You don't show what the values of Birthmonth etc look like.
If they are numeric values then the better approach would be
Birthdt = mdy(birthmonth, birthday, birthyear);
format birthdt date9.;
You don't show what the values of Birthmonth etc look like.
If they are numeric values then the better approach would be
Birthdt = mdy(birthmonth, birthday, birthyear);
format birthdt date9.;
Sorry about that, the date variables are as follows:
BirthMonth: 12
BirthDay: 7
BirthYear: 1995
If you will be working with dates much you may want to check out: https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
Hello!
Try using an assignment statement to concatenate the date variables into a singular numeric variable.
DATA WORK.Want;
SET WORK.Have;
BirthDt = MDY(BirthMonth, BirthDay, BirthYear);
RUN;
I hope this was helpful!
- A.G.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.