SAS Optimization, and SAS Simulation Studio

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 10:08 AM

Hello my name is Kendall. I am trying to teach myself how to use SAS studio. I have little knowledge on it but have learned a lot in the past couple of days. My ultimate goal is to become efficient in learning how to use the program and learn coding. I would also like to build an optimization model for my fantasy basketball team. Where i have to pick 8 players, one in each position of PG,SG,SF,PF,C G, F and Util…. The G can be either PG or SG. The F can be either SF or PF and the UTIL can be any one of the original 5 listed. I was wondering if you guys would be able to help me and teach me at the same time. I have attached the data i use and created in excel just to give you an idea of what i will be working with.

There are also certain criteria that needs to be meet with this optimal lineup. The players combined can not exceed $50,000 price tag. I would like to use USG and DvP and Projections columns to choose the top players. I would actually like to use a lot more but i can implement that later once i learn to develop it on my own. If you guys would be able to assist me i would greatly appreciate it.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 10:11 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 10:16 AM

I read up on this but like i said I'm a noob and didn't really understand how to use it with my certain situation..

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 10:40 AM

Okay, I will try to nutshell this:

To solve this kind of problem, the best way (also the official way) is Proc OPTModel, which is part of SAS OR, is an expert and his code in the referred thread is not difficult to follow. I am not sure about your SAS studio, if it is the element that goes with EBI system for your organization, you need to check; if it is the free University edition, you are out of luck.

Another way to tackle it requires sophisticated SAS programming skills, and so far it can't compete PROC OPTMODEL on both performance and reliability. but you said you are a noob?

My suggestion will be trying to find a SAS box that has SAS OR.

Good luck,

Haikuo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 10:58 AM

well then... lol.. I'm on SAS studio... and a noob.. i guess I'm out of luck.. haha... thanks for the replies though buddy.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 03:26 PM

For Draft Kings, the model would look something like this...

I am leaving out some details about how the data is pulled in from Excel (my Excel projection sheet is probably different than yours). The basic model is mostly here. The only rule I left out is that players must be selected from two different teams. But, in my experience, this hardly ever happens in practice.

Good luck - if you figure out how to beat Draft Kings - please let me know!

set<str> PLAYERS;

num salary{PLAYERS};

num points{PLAYERS};

str team{PLAYERS};

str position{PLAYERS};

read data dk_data into PLAYERS=[player] position salary points=Projected_Fantasy_Points team;

set<str> POSITIONS = union{p in PLAYERS}{position

};

num required = 8;

/* >= 1 PG, 1 SG, 1 SF, 1C

>= 1 PG or SG

>= 1 PF or SF

>= 1 PG or SG or PF or SF = UTIL */

num requiredMin{POSITIONS} = [["PG"] 1 ["SG"] 1 ["SF"] 1 ["PF"] 1 ["C"] 1];

num budget = 50000;

var x{p in PLAYERS} binary;

max TotalPoints = sum{p in PLAYERS} x

* points

;

con budgetcon:

sum{p in PLAYERS} x

* salary

<= budget;

con positionTotal:

sum{p in PLAYERS} x

= required;

con positionMin{i in POSITIONS}:

requiredMin* <= sum{p in PLAYERS : position*

=i} x

;

con positionGuard:

sum{p in PLAYERS : position

="PG" or position

="SG"} x

>= 3;

con positionForward:

sum{p in PLAYERS : position

="PF" or position

="SF"} x

>= 3;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 03:48 PM

hey thanks Matthew.. i'll look into and see what i can do... Im still new to SAS so all that looks like just a bunch of words and symbols typed together... I have an excel spreadsheet that i update everyday.. its pretty good.. it tells me who will actually have a good game.. BUT because my mind works a certain way and its a 50,000 cap limit i don't/can't choose who i know will ball.. so i always have like one or two guys do bad... then my other ones do good... my lineups are good for Head to heads and 50/50... which i have no problem with. but i want to win the GPP's haha... I use solver also... but it only judges by the projections.. i need it to factor in a few other things because projections are good but with my experience some of the advanced stats tell you who will explode.. so i was trying to build a model on SAS to factor in more than one thing.. but i guess I'm back to the drawing board for now haha

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 03:57 PM

Yep. The optimization part is not very useful if the projections are not accurate. That part is a whole field of study in itself - and, of course, using SAS makes sense for that part too. By the way, a nice Excel based product is: Spreadsheet Sports - Daily Fantasy Sports Tools & Analytics. Tell them Matt sent you.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 04:17 PM

Yea i used to use spreadsheet sports last year.. then i was like what the heck let me learn to build my own.. so a year later i've done countless amounts of readings and youtube vids to better myself with excel... and i must say I've gotten pretty good at it now.. so I guess i'll have to just keep doing what i am doing for now... i'll keep implementing more and more to help me get closer to cracking the code for DK haha.. i appreciate your responses though... if you ever want to team up or put our ideas together just shoot me an email kpee44@gmail.com

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-31-2017 01:09 PM

Hello Matthew,

Thank you for this code.

What is the p in players section? When I try to run the code I am getting the following error:

ERROR The name 'position' is an array

This is happening at the union{p in players}{position};

Thanks for your help!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-01-2017 12:08 PM - edited 02-01-2017 12:31 PM

Looks like each occurrence of [p] or [i] in the code was treated as markup and so got mangled in the display. Here it is again as a SAS code block:

```
proc optmodel;
set<str> PLAYERS;
num salary{PLAYERS};
num points{PLAYERS};
str team{PLAYERS};
str position{PLAYERS};
read data dk_data into PLAYERS=[player] position salary points=Projected_Fantasy_Points team;
set<str> POSITIONS = union{p in PLAYERS}{position[p]};
num required = 8;
/* >= 1 PG, 1 SG, 1 SF, 1C
>= 1 PG or SG
>= 1 PF or SF
>= 1 PG or SG or PF or SF = UTIL */
num requiredMin{POSITIONS} = [["PG"] 1 ["SG"] 1 ["SF"] 1 ["PF"] 1 ["C"] 1];
num budget = 50000;
var x{p in PLAYERS} binary;
max TotalPoints = sum{p in PLAYERS} x[p] * points[p];
con budgetcon:
sum{p in PLAYERS} x[p] * salary[p] <= budget;
con positionTotal:
sum{p in PLAYERS} x[p] = required;
con positionMin{i in POSITIONS}:
requiredMin[i] <= sum{p in PLAYERS : position[p]=i} x[p];
con positionGuard:
sum{p in PLAYERS : position[p]="PG" or position[p]="SG"} x[p] >= 3;
con positionForward:
sum{p in PLAYERS : position[p]="PF" or position[p]="SF"} x[p] >= 3;
solve;
create data lineup from [p]={p in PLAYERS : x[p]>0.5} position salary points team;
quit;
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-01-2017 04:24 PM

Hello Rob,

That worked! Thank you so much for your help!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 10:12 AM

Trying to beat Draft Kings?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-28-2015 10:15 AM

lol.. oh but yes i am!! haha... I used solver with excel BUT i can't get it to implement other factors besides just the projections...