BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SAScowboy
Fluorite | Level 6

I need help adding a constraint to the below model that restricts the sum of "buy" for even numbered adwords to be at most 10.

proc optmodel;
set ADWORDS = 1..100;
num cost_per_click{ADWORDS} = ranuni(123);
num clicks{ADWORDS} = ranuni(567);
num conversions{ADWORDS} = ranuni(789);
num revperconversion=10;
var buy{ADWORDS} >=0;
max effectiveness =sum{a in ADWORDS}((revperconversion*conversions[a])-(clicks[a]*cost_per_click[a]))*buy[a];
con buyAtMost50: sum{a in ADWORDS}buy[a]<=50;
solve;
Quit;

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

Here are two ways:

con buyAtMost10even: sum {a in ADWORDS: mod(a,2) = 0} buy[a] <= 10;
con buyAtMost10even: sum {a in 2..100 by 2} buy[a] <= 10;

View solution in original post

2 REPLIES 2
RobPratt
SAS Super FREQ

Here are two ways:

con buyAtMost10even: sum {a in ADWORDS: mod(a,2) = 0} buy[a] <= 10;
con buyAtMost10even: sum {a in 2..100 by 2} buy[a] <= 10;
SAScowboy
Fluorite | Level 6
Thank you so much. I’m still learning.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 2 replies
  • 983 views
  • 3 likes
  • 2 in conversation