BookmarkSubscribeRSS Feed
er7212
Fluorite | Level 6

Hi

 

I have a fairly large set that includes names of cars I'd like to run my optimization over, call it 'SERIES' for the sake of conversation. Here is a snapshot of how I define and read the 'SERIES' in PROC OPTMODEL:

 

 

PROC OPTMODEL;
...
SET <STR> SERIES;
...
READ DATA OPT_DATA_SERIES INTO SERIES = [SERIES];
...

 

This 'SERIES' includes a large number of car names. What I'd like to do is to pick a subset of these (maybe with the help of macro variables) and define couple of constraints that only needed to be applied to those subset.

 

 

 

IMPVAR SUBSET_SPEND = SUM{I IN SERIES: I IN &MYSUBSET.} SERIES_SPEND[I];

 

Q1. Is the following part {...  : I IN &MYSUBSET. } correct way to do this?

Q2. I have seen something like {I IN /'MYSUBSET'/}, but I have no idea what it means and how I can use this format? 

 

Appreciate any words of wisdom anyone could share.

 

 

 

2 REPLIES 2
pink_poodle
Barite | Level 11

You may want to subset the dataset before feeding it to OPTMODEL.

 

data lesscars;

set cars;

keep &mylist;

run;

 

proc optmodel;

...

RobPratt
SAS Super FREQ

If you want to ignore all the other observations, you can use the DATA set WHERE= option in the READ DATA statement.

 

Also, if MYSUBSET is a subset of SERIES, you can avoid the logical condition and just do:

SUM{I IN MYSUBSET}

The correct syntax depends on what &MYSUBSET. looks like.

 

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
  • 1922 views
  • 0 likes
  • 3 in conversation