BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
strong_s
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.;

View solution in original post

5 REPLIES 5
ballardw
Super User

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.;

strong_s
Fluorite | Level 6

Sorry about that, the date variables are as follows:

BirthMonth: 12

BirthDay: 7

BirthYear: 1995

strong_s
Fluorite | Level 6
This worked! Thank you so much!
ballardw
Super User

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.

GoldingAngela
Fluorite | Level 6

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2392 views
  • 0 likes
  • 3 in conversation