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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Multiple Linear Regression in SAS

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.

Discussion stats
  • 2 replies
  • 1610 views
  • 0 likes
  • 3 in conversation