BookmarkSubscribeRSS Feed
Calcite | Level 5


Please excuse me for requesting help with what is likely a very simple linear programming problem. Attached is an example SAS data set with the number of staff needed each hour. What I would like to do is optimize the staff schedule with certain constraints (that could be changed in the future) primary with respect to shift length. For example shifts should be a minimum of 4 hours long (increasing in increments of 2 hours), and a maximum shift length of 12 hours.

Shift start times should either be at the top of the hour or the bottom of the hour.

My goal is to set up a macro that will generate a schedule for each day uniquely, 365 days per year based on the calculated workload for each hour.

Does anyone have any suggestions? If this problem would be better solved using an approach other than linear programming please make recommendations.

In case you are wondering this data represents the nurse staffing needs in a emergency department for a given day.

Any thoughts or suggestions appreciated.



SAS Employee

Hi Kevin,

There exist simple models that do a portion of what you are describing. There are also some very sophisticated models for workforce scheduling. Because the requirements can be so diverse, and getting the right people working in the right place is so important, it is often worth the expense to have an expert discuss specific requirements.

Here is some academic information to get you in the right direction: SAS/OR(R) 12.1 User's Guide: Mathematical Programming Examples. Experimenting in PROC OPTMODEL is much easier and much more fun than using PROC LP directly. Let me know if these examples are helpful. If you get stuck, post your work in progress here and people will help you as time permits.

If you have a strong business constraint that prevents you from posting your business rules on this forum, there is a consulting group specialized in SAS/OR that can help. It is called the AAOS. You can find more information about some of the people involved by searching for AAOS here: Analytics Conference 2012.

Good luck,


Calcite | Level 5

Thanks very much for your suggestions and information...I'll look into them straight away.

Thanks again.




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2 in conversation