DATA Step, Macro, Functions and more

Concatenating two dates

Reply
New Contributor LNM
New Contributor
Posts: 3

Concatenating two dates

I need help concatenating my two dates to a comment field.  Here's what I have

DATA PRX;

SET BICS_02;

format prx_startdt prx_enddt mmddyy10.;      /*format to mm/dd/yyyy*/

prx_startdt = datepart(Optional_1_start_date);      /*optional date is date and time*/

prx_enddt = datepart(Optional_1_end_date);        /*optional date is date and time*/

period_comments = prx_startdt||" to "||prx_enddt;      /*combine the dates in comment "start date to end date"*/

run;

prx_startdt and prx_enddt just post the date values.  I have converted it to the right format but in the doesn't translate correctly to my comments field.  Please help.

Super User
Posts: 5,516

Re: Concatenating two dates

Try it this way:

 

period_comments = put(prx_startdt, mmddyy10.) || " to " || put(prx_enddt, mmddyy10.); 

 

 

PROC Star
Posts: 1,760

Re: Concatenating two dates

[ Edited ]
Posted in reply to Astounding

Since the variable already has a format, this works too:

 

PERIOD_COMMENTS = vvalue(PRX_STARTDT) || ' to ' || vvalue(PRX_ENDDT); 

 

New Contributor LNM
New Contributor
Posts: 3

Re: Concatenating two dates

Thanks a lot, it works!!

New Contributor LNM
New Contributor
Posts: 3

Re: Concatenating two dates

Posted in reply to Astounding

Thank you, it works!

Ask a Question
Discussion stats
  • 4 replies
  • 131 views
  • 0 likes
  • 3 in conversation