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

Hello Everyone,

 

Greetings!!

 

My requirement is quite simple but i am struggling to get the expected output using SAS.

 

DayStart_timeEnd_time
Monday 8:00:00 AM12:00:00 PM
Monday 1:00:00 AM9:00:00 PM
Tuesday 8:00:00 AM9:00:00 PM
Wednesday8:00:00 AM9:00:00 PM
Thursday 8:00:00 AM9:00:00 PM
Friday 8:00:00 AM9:00:00 PM
Saturday 8:00:00 AM9:00:00 PM
Sunday 8:00:00 AM9:00:00 PM

 

Expected Result:

 

DayStart_timeEnd_timeExpected_Result
Monday 8:00:00 AM12:00:00 PMMonday   08:00 AM - 12:00 PM
Monday 1:00:00 AM9:00:00 PMMonday   01:00 PM - 09:00 PM
Tuesday 8:00:00 AM9:00:00 PMTuesday  08:00 AM - 09:00 PM
Wednesday8:00:00 AM9:00:00 PMWednesday 08:00 AM - 09:00 PM
Thursday 8:00:00 AM9:00:00 PMThursday  08:00 AM - 09:00 PM
Friday 8:00:00 AM9:00:00 PMFriday   08:00 AM - 09:00 PM
Saturday 8:00:00 AM9:00:00 PMSaturday  08:00 AM - 09:00 PM
Sunday 8:00:00 AM9:00:00 PMSunday   08:00 AM - 09:00 PM
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

 

length Expected_Result $50;

Expected_Result=catx(' ',day,catx('-',Start_time,End_time));

 

 

Notes: If you are time variables are numeric, please make sure you convert to char and then concatenate

--> To convert to char, you would use PUT function 

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

 

length Expected_Result $50;

Expected_Result=catx(' ',day,catx('-',Start_time,End_time));

 

 

Notes: If you are time variables are numeric, please make sure you convert to char and then concatenate

--> To convert to char, you would use PUT function 

sarav93
Fluorite | Level 6
Thankyou :). its working fine now

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 507 views
  • 1 like
  • 2 in conversation