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

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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
  • 2 replies
  • 868 views
  • 1 like
  • 2 in conversation