We’re smarter together. Learn from this collection of community knowledge and add your expertise.

How to Write Constraints that Use Percentages in SAS Marketing Optimization

by SAS Employee Patricia_SAS on ‎03-10-2017 09:21 AM - edited on ‎03-10-2017 09:33 AM by Community Manager (922 Views)


This tech tip describes how to implement constraints that use percentages in SAS Marketing Optimization (MO).

An example of these constraints would be:


We don’t know the total capacity of a channel in a given day, but we know that we want at most 60% of that channel capacity to be allocated to Mortgage and Deposit campaigns, and the remaining capacity (at most 40%) to be allocated to Online and Visa campaigns.


This tech tip uses the MO Sample Library available in all MO installations, and the example is developed using a demo instance that SAS has created for examples and education. There are four types of campaigns in this library: Mortgage, Deposit, Visa and Online.


Agents in MO

Agents are considered outbound channels in MO. The MO User Guide provides plenty of information about Agents. For this tech tip it will suffice with remembering these key items:


  1. An agent is related to many customers. A customer can only have one agent.
  2. Each agent has a unit_usage and capacity. Unit_usage specifies, on average, how much of the agent is used for each communication that uses that specific agent, and capacity indicates what is the max limit that each agent can be used during each time period when the optimization will run.

Sometimes the concepts are easier to understand if we have a concrete example. Let’s assume that the campaigns are optimized daily, and three channels are used: DM, email and Agent. Let’s assume that the agent unit_usage is 0.25 (per agent) and his capacity is 4 per day. That means, that a call from this agent takes approximately 0.25 hours (or 15 minutes), and the agent is available for 4 hours of calls, which means that he could reach up to 16 customers per day.


Measures in MO

Several Indicator and Calculated measures must be created to implement percentages. To illustrate that concept the goal in this Tech Tip is to create measures that allow us: a) to allocate 60% of the total agent capacity to the Mortgage and Deposit campaigns, and b) to allocate the remaining 40% of agent capacity to the Online and Visa campaigns. An indicator measure enables us to create a binary attribute that subsets the communications or customers based on character or numeric attributes. They can be used in other communication or customer filters, such as in suppression rules, constraints, or contact policies. For this Tech Tip, three Indicator measures were created: AgentsInMortgageAndDeposit, AgentsInMortgageAndDeposit and TotalAgentComm.


The photo below shows the filters used to create the Indicator measure AgentsInMortgageAndDeposit; this measure is related to the Agents used in the Deposit and Mortgage campaigns.




These were the filters used to create the Indicator measure AgentsOnlineAndVisa; this measure is related to the Agents used in the Online and Visa campaigns.




The Indicator variable TotalAgentComm represents all the agents used in this MO scenario, that is, all agents used for all possible campaigns in this scenario: Mortgage, Deposit, Online and Visa campaigns.





Three calculated variables must be created one for each one of these three Indicator variables as the photo below shows.



Then one uses these variables to create constraints, as described in the next photos. The constraint agentsInMortAndDep indicates that at most 60% of the total agent capacity must be allocated to the Mortgage and Deposit campaigns. If one wants equality to 60%, then one must write an "at least" constraint.


photo 5.jpg


Similarly, write a constraint that indicates that at most 40% of the total agent capacity must be allocated to the Visa and Online campaigns. For equality, also write an "at least" constraint.


Caution: To avoid infeasible scenarios due to limited resources, start "only" with the "at most" constraints. In total four constraints must be written as the last four constraints in the photo below




Run the scenario and check it is optimized.



Once the scenario is optimized, to verify the constraints are satisfied we can run in Enterprise Guide this code:



libname agentP "<path>\percentageAgentEquality_651\solution";
proc sql feedback outobs=5;
	select * from agentP.mo_solution;
proc sql;
	select sum(TOTALAGENTS) as totalAgent, 
		sum(TOTALMORTGANDDEPOSIT) as totalMortgageAndDeposit,
		sum(TOTALONLINEANDVISA) as totalOnlineAndVisa,
		calculated totalMortgageAndDeposit / calculated totalAgent as ratioMortgageAndDeposit, 
		calculated totalOnlineAndVisa / calculated totalAgent as ratioOnlineAndVisa
	from agentP.mo_solution;



Here is the output of running the code, which indicates the constraints are satisfied: