a lotto sas for you l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
A “LOTTO” SAS for you! PowerPoint Presentation
Download Presentation
A “LOTTO” SAS for you!

Loading in 2 Seconds...

play fullscreen
1 / 16

A “LOTTO” SAS for you! - PowerPoint PPT Presentation


  • 133 Views
  • Uploaded on

A “LOTTO” SAS for you!. or, “Check Your Balls with SAS Arrays”. By Keith McWhorter Georgia Technology Authority January 30, 2007. A Mega-Group Effort. When Mega-Millions’ Jackpot > $50Mil People in the office put in $1 - $5 each Usually get 75 to 100 tickets

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'A “LOTTO” SAS for you!' - deirdra


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
a lotto sas for you

A “LOTTO” SAS for you!

or, “Check Your Balls with SAS Arrays”

By

Keith McWhorterGeorgia Technology AuthorityJanuary 30, 2007

a mega group effort
A Mega-Group Effort
  • When Mega-Millions’ Jackpot > $50Mil
  • People in the office put in $1 - $5 each
  • Usually get 75 to 100 tickets
  • Could take a while to check them all!
ways to win
Ways to Win
  • 5 numbers plus Mega Ball
  • Match only Mega Ball wins small amount
  • Match 1 or more of the first 5 + Mega
  • If Mega doesn’t match – must have at least 3 of the 5 others.
let sas check em
Let SAS Check ‘em!

Input file:

01/09/2007 07 11 26 38 54 13  Draw Date & winning #s

01 02 31 45 55 35

01 03 30 42 46 24

07 11 26 36 50 34

01 20 36 44 53 31

02 04 24 35 53 23

02 08 11 20 55 19

02 10 38 43 46 18

02 11 19 22 34 20

02 14 28 29 44 28

03 08 17 19 48 18

the code
The Code

DATA results(KEEP=ldate w1 w2 w3 w4 w5 w6)

ournums(KEEP=d1 d2 d3 d4 d5 d6

flg1 flg2 flg3 flg4 flg5 flg6);

INFILE 'SGSS.KEITH.GA010907';

ARRAY WIN[6] 2 WIN1-WIN6; *WINNING NUMBERS ;

ARRAY FLG[6] $ 2 FLG1-FLG6; * Match Flags = Y or N ;

RETAIN WIN1-WIN6; * KEEP WINNING NUMS IN MEMORY ;

first time through
First Time Through…

IF _N_=1 THEN DO;

INPUT ldate MMDDYY10. W1 W2 W3 W4 W5 W6 ;

WIN[1] = W1;

WIN[2] = W2;

WIN[3] = W3;

WIN[4] = W4;

WIN[5] = W5;

WIN[6] = W6;

OUTPUT results;

END;

read a set of our numbers check
Read a set of our numbers & check

ELSE DO;

INPUT D1 D2 D3 D4 D5 D6;

ARRAY OUR[6] 2 D1 D2 D3 D4 D5 D6; * OUR NUMBERS;

FLG[6]='N';

IF OUR[6] = WIN[6] THEN FLG[6]='Y'; *Mega?;

DO I = 1 TO 5; *Loop through other 5;

IF OUR[I]=WIN[1]

OR OUR[I]=WIN[2]

OR OUR[I]=WIN[3]

OR OUR[I]=WIN[4]

OR OUR[I]=WIN[5]

THEN FLG[I]='Y'; *Set flag if match;

ELSE FLG[I]='N';

END;

OUTPUT ournums; *Write it out!;

END;

add var x with matches
Add Var “x” with # matches

DATA wincnt;

SET ournums;

x=0;

IF FLG1 = 'Y' then x+1;

IF FLG2 = 'Y' then x+1;

IF FLG3 = 'Y' then x+1;

IF FLG4 = 'Y' then x+1;

IF FLG5 = 'Y' then x+1;

run;

determine level of win
Determine Level of Win

DATA winlvl;

SET wincnt;

IF FLG6 = 'Y' then do; * if megaball matches... ;

SELECT;

WHEN (X = 5) L=1;

WHEN (X = 4) L=2;

WHEN (X = 3) L=3;

WHEN (X = 2) L=4;

WHEN (X = 1) L=5;

WHEN (X = 0) L=6;

END; * end select ;

END; * end if ;

determine level of win10
Determine level of win…

ELSE DO; * megaball does not match ;

SELECT;

WHEN (X = 5) L=7;

WHEN (X = 4) L=8;

WHEN (X = 3) L=9;

OTHERWISE DELETE;

END; * end select;

END; * end else;

run;

format the levels
Format the Levels

PROC FORMAT;

VALUE lvl

1 = ' JACKPOT!!'

2 = ' 4 + MB'

3 = ' 3 + MB'

4 = ' 2 + MB'

5 = ' 1 + MB'

6 = ' 0 + MB'

7 = ' 5 of 5'

8 = ' 4 of 5'

9 = ' 3 of 5'

;

RUN;

email the results
Email the Results!

FILENAME MY_FILE EMAIL

FROM=("Mega_Mil@gta.ga.gov")

TO=("kmcwhort@gta.ga.gov"

)

SUBJECT="Group A Results"

TYPE="TEXT/HTML" ;

RUN;

ODS listing close;

ODS HTML BODY=MY_FILE;

first the winning numbers
First the Winning Numbers

PROC PRINT data=results noobs split='*';

by ldate;

format ldate MMDDYY10.;

title 'Results for #byval1';

title2 'Winning Numbers';

var w1 w2 w3 w4 w5 w6;

label w1 = '* '

w2 = '* '

w3 = '* '

w4 = '* '

w5 = '* '

w6 = '* '

ldate = ' '

;

run;

now print our matches
Now Print Our Matches

PROC PRINT data=winlvl noobs split='*';

title 'Our Winning Numbers';

footnote 'Total Winnings = $6!'; *Manual ;

format L lvl.;

var d1 d2 d3 d4 d5 d6 L;

label d1 = '* '

d2 = '* '

d3 = '* '

d4 = '* '

d5 = '* '

d6 = '* '

L = '# of*Matches'

;

run;

ods html close;