Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- First Work Day after the mid point between two dat...

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-09-2013 06:09 AM

All.

I'm very new to SAS and have a taks to calculate a field that:

Finds the mid point between two date fields. They are 'from' and 'to' date fields so am pretty confident the 'to' field will always be later than the 'from' field.

If the resulting day is a non working day (ie saturday or sunday), then provide the next working day (ie mon, tue, wed, thurs, fri). else provide the exact midpoint day.

Hope this makes sense!! NB they are DATE fields not DATETIME fields.

Accepted Solutions

Solution

01-09-2013
06:17 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-09-2013 06:17 AM

You can find the midpoint as the mean between the two dates (so order does not matter anyway). I would suggest using the ceil function to round up to the next day in the case of a fractional result. Then use the Weekday() function to detect day of week: if the result is 1 (Sunday) add a dy, else if it is 7 (Saturday) add 2 days.

Richard

All Replies

Solution

01-09-2013
06:17 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-09-2013 06:17 AM

You can find the midpoint as the mean between the two dates (so order does not matter anyway). I would suggest using the ceil function to round up to the next day in the case of a fractional result. Then use the Weekday() function to detect day of week: if the result is 1 (Sunday) add a dy, else if it is 7 (Saturday) add 2 days.

Richard

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-09-2013 07:03 AM

Worked brilliantly - Thanks very much!