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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.