Hi All,
I used SAS/OR proc optmodel before in order to find a solution. But that's for a single number.
Now I need to randomly pick 100 records from 1000 records. There is another constaint, the sum of these 100 records must be a ceterain number (K).
So the constaints are: sum of the total number of records is 100 and the sum of records is K.
Where can I start? I look up some of examples but I cannot find anything similar.
Thanks
I think you want to declare a binary variable for each record and then declare your two constraints, like this:
set RECORDS;
num a {RECORDS};
read data indata into RECORDS=[record] a;
var X {RECORDS} binary;
con NumberRecords:
sum {r in RECORDS} X[r] = 100;
con SumRecords:
sum {r in RECORDS} a[r]*X[r] = k;
I think you want to declare a binary variable for each record and then declare your two constraints, like this:
set RECORDS;
num a {RECORDS};
read data indata into RECORDS=[record] a;
var X {RECORDS} binary;
con NumberRecords:
sum {r in RECORDS} X[r] = 100;
con SumRecords:
sum {r in RECORDS} a[r]*X[r] = k;
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.