or, “Check Your Balls with SAS Arrays”

Slides:



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

Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.
Trials and Tribulations of creating DDI Codebooks at the University of Guelph A.Michelle Edwards and Carol Perry, Data Resource Centre, University of Guelph.
CSI 101 Elements of Computing Spring 2009 Lecture #5 Designing with Pseudocode Wednesday, February 4th, 2009.
PROC_CODEBOOK: An Automated, General Purpose Codebook Generator
How to Build Tabular Dashboards Using Proc Report
Data Cleaning 101 Ron Cody, Ed.D Robert Wood Johnson Medical School Piscataway, NJ.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Lecture 5 Sorting, Printing, and Summarizing Your Data.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
I OWA S TATE U NIVERSITY Department of Animal Science Getting Your Data Into SAS (Chapter 2 in the Little SAS Book) Animal Science 500 Lecture No. 3 September.
01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.
1 Efficient SAS Coding with Proc SQL When Proc SQL is Easier than Traditional SAS Approaches Mike Atkinson, May 4, 2005.
1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University.
Publishing to PDF SNUG Quarter 2. Overview n What is PDF? n Why use PDF? n Creating PDF files with SAS Software n Issues n Advanced PDF files with SAS.
Lesson 6 - Topics Reading SAS datasets Subsetting SAS datasets Merging SAS datasets.
Computing with SAS Software A SAS program consists of SAS statements. 1. The DATA step consists of SAS statements that define your data and create a SAS.
FORMAT statements can be used to change the look of your output –if FORMAT is in the DATA step, then the formats are permanent and stored with the dataset.
Learning Javascript From Mr Saem
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
Files in Python Opening and Closing. Big Picture To use a file in a programming language – You have to open the file – Then you process the data in the.
Build your Metadata with PROC CONTENTS and ODS OUTPUT Louise S. Hadden Abt Associates Inc.
Better Metadata Through SAS® II: %SYSFUNC, PROC DATASETS, and Dictionary Tables.
Beautiful PROC CONTENTS Output Using the ODS Excel Destination Suzanne Dorinski SESUG 2015 Disclaimer: Any views expressed are those of the author and.
Functions, Scope & File IO C++ Lecture 4 Bhaskar Bhattacharya.
Customer Report Manual
Chapter 11 Reading SAS Data
By Sasikumar Palanisamy
Applied Business Forecasting and Regression Analysis
DePaul Bears Try Your Luck!.
Dynamic Array Multidimensional Array Matric Operation with Array
Python’s input and output
SAS Macro Language.
Chapter 3: Working With Your Data
SAS Workshop SAS Data Management Hun Myoung Park, Ph.D.
SAS Output Delivery System
Instructor: Raul Cruz-Cano
Chapter 22 Reading Hierarchical Files
Chapter 4: Sorting, Printing, Summarizing
SAS Essentials How SAS Thinks
مفاهیم بهره وري.
Ex (pp. 430) OPTIONS NOOVP NODATE NONUMBER; proc format;
More Loops.
In Class Programming BIS1523 – Lecture 11.
Beautiful PROC CONTENTS Output Using the ODS Excel Destination
USA Today, October 9, 2014.
Introduction to DATA Step Programming SAS Basics II
SESUG Web Scraping in SAS: A Macro-Based Approach
Video list editor BIS1523 – Lecture 24.
3 Iterative Processing.
Hunter Glanz & Josh Horstman
Introduction to DATA Step Programming: SAS Basics II
Working With Dates: Dates Come in Many Ways
Python programming exercise
Examples Example Problems, their Algorithms, and their C Source Code.
Automating SAS through the Power of VB Script
Purpose Real life scenario: I have a set of reports to refresh every month but data is only available at any day during Day 3 – 5 at beginning of each.
Basic Lessons 5 & 6 Mr. Kalmes.
Study on Learning Effect in Visuomotor Tracking
Tips and Tricks for Using Macros to Automate SAS Reporting.
Dry Run Fix it Write a program
This is an introduction to JavaScript using the examples found at the CIS17 website. In previous examples I specified language = Javascript, instead of.
Hans Baumgartner Penn State University
Lec 21 More Fun with Arrays: For Loops
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Why We Need Car Parking Systems - Wohr Parking Systems
Types of Stack Parking Systems Offered by Wohr Parking Systems
Writing Robust SAS Macros
Changing a file from being long to being wide*
Add Title.
Presentation transcript:

or, “Check Your Balls with SAS Arrays” 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 Could take a while to check them all!

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! 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 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… 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 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!;

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

The Resulting Email

Thank you!