Download presentation

Presentation is loading. Please wait.

Published byPhillip Deming Modified over 2 years ago

1
A “LOTTO” SAS for you! or, “Check Your Balls with SAS Arrays” By Keith McWhorter Georgia Technology Authority January 30, 2007

2
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!

3
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.

4
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 …

5
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] $ 2FLG1-FLG6; * Match Flags = Y or N; RETAIN WIN1-WIN6;* KEEP WINNING NUMS IN MEMORY ;

6
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;

7
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; IFOUR[I]=WIN[1] OROUR[I]=WIN[2] OROUR[I]=WIN[3] OROUR[I]=WIN[4] OROUR[I]=WIN[5] THEN FLG[I]='Y'; *Set flag if match; ELSE FLG[I]='N'; END; OUTPUT ournums; *Write it out!; END;

8
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;

9
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 ;

10
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;

11
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;

12
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;

13
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;

14
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;

15
The Resulting Email

16
Thank you!

Similar presentations

OK

EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.

EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on impact of social networking sites Neurological anatomy and physiology ppt on cells Jit ppt on manufacturing overhead Free download ppt on transportation in plants Ppt on uses of soil Ppt on human eye and colourful world free download Download seminar ppt on graphical password authentication Viewer ppt online reader Ppt on communist party of india Ppt on cv writing