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.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1425 views
  • 0 likes
  • 3 in conversation