Hello Everyone,
Greetings!!
My requirement is quite simple but i am struggling to get the expected output using SAS.
Day | Start_time | End_time |
Monday | 8:00:00 AM | 12:00:00 PM |
Monday | 1:00:00 AM | 9:00:00 PM |
Tuesday | 8:00:00 AM | 9:00:00 PM |
Wednesday | 8:00:00 AM | 9:00:00 PM |
Thursday | 8:00:00 AM | 9:00:00 PM |
Friday | 8:00:00 AM | 9:00:00 PM |
Saturday | 8:00:00 AM | 9:00:00 PM |
Sunday | 8:00:00 AM | 9:00:00 PM |
Expected Result:
Day | Start_time | End_time | Expected_Result |
Monday | 8:00:00 AM | 12:00:00 PM | Monday 08:00 AM - 12:00 PM |
Monday | 1:00:00 AM | 9:00:00 PM | Monday 01:00 PM - 09:00 PM |
Tuesday | 8:00:00 AM | 9:00:00 PM | Tuesday 08:00 AM - 09:00 PM |
Wednesday | 8:00:00 AM | 9:00:00 PM | Wednesday 08:00 AM - 09:00 PM |
Thursday | 8:00:00 AM | 9:00:00 PM | Thursday 08:00 AM - 09:00 PM |
Friday | 8:00:00 AM | 9:00:00 PM | Friday 08:00 AM - 09:00 PM |
Saturday | 8:00:00 AM | 9:00:00 PM | Saturday 08:00 AM - 09:00 PM |
Sunday | 8:00:00 AM | 9:00:00 PM | Sunday 08:00 AM - 09:00 PM |
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
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.