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.
You may want to subset the dataset before feeding it to OPTMODEL.
data lesscars;
set cars;
keep &mylist;
run;
proc optmodel;
...
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.
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.
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.