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

Hello,

how do you define a constraint for a specific set of variales (using "in" not GE or LE, etc.)? For example, instead of:

Con Cns_Ex{c in Components:c="R2"}:Sum{p in Products} X

*Qty[p,c]<=8;

I would like something similar to:

Con Cns_Ex{c in Components:c in ("R2", "R5")}:Sum{p in Products} X

*Qty[p,c]<=8

Thanks&best regards

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

Here are two ways (note the curly braces instead of parentheses):

Con Cns_Ex{c in Components:c in {"R2", "R5"}}:Sum{p in Products} X

*Qty[p,c]<=8;

Con Cns_Ex{c in Components inter {"R2", "R5"}}:Sum{p in Products} X

*Qty[p,c]<=8;

If you know that "R2" and "R5" are both in Components, you can make it even simpler:

Con Cns_Ex{c in {"R2", "R5"}}:Sum{p in Products} X

*Qty[p,c]<=8;

View solution in original post

1 REPLY 1
RobPratt
SAS Super FREQ

Here are two ways (note the curly braces instead of parentheses):

Con Cns_Ex{c in Components:c in {"R2", "R5"}}:Sum{p in Products} X

*Qty[p,c]<=8;

Con Cns_Ex{c in Components inter {"R2", "R5"}}:Sum{p in Products} X

*Qty[p,c]<=8;

If you know that "R2" and "R5" are both in Components, you can make it even simpler:

Con Cns_Ex{c in {"R2", "R5"}}:Sum{p in Products} X

*Qty[p,c]<=8;

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
  • 1 reply
  • 1160 views
  • 0 likes
  • 2 in conversation