SAS Enterprise Guide: Pick a Winner Randomly
To pick the winners of the 50 Keys to Learning SAS Stored Processes book, my first thought was to print the list and then put everyone’s name in a hat. Angela brilliantly suggested that we use one of the SAS Random functions. However, since there was a list of names I really needed a random number between two values. This brought to mind the MS Excel RANDBETWEEN function – but how do you translate that function to SAS Enterprise Guide code?
Getting a Random Number between Two Values
I have to admit for a one-off process like picking a random number, MS Excel would be my goto tool. MS Excel has a function called RANDBETWEEN() that allows you to provide two numbers and it then selects a random value between those two numbers. I tried to use the SAS RANDOM functions – but I couldn’t figure out how to make it work in 5 minutes (my personal patience meter) so I needed an expert.
Consult with a SAS Expert
Lucky for me SAS-L had the answer – it’s one of the places I search for SAS tips when I’m stuck. In August 2000, Mark Terjeson wrote a post called “Just for Fun: Excel-SAS Corollary Functions/Formula” describing how to translate some common Excel functions into SAS. This is where I found the magic. In the following figure, you can see the code I used to select the two winning numbers. After getting my two numbers, I matched the line number to the spreadsheet line number to get Michelle Homes and Wex Lee. Congratulations you have won a copy of the 50 Keys to Learning SAS Stored Processes!
No Worries if You are not the Winner!
Never miss a BI Notes post!
Click here for free subscription. Once you subscribe you'll be asked to confirm your subscription through your email account. You email address is kept private and you can unsubscribe anytime.
Latest posts by Tricia Aanderud (see all)
- Designing Dashboards: Sending Your Style Vibe - 2017-01-21
- SAS Visual Analytics: Design Versus Reality - 2016-10-05
- Seize the Day! Submit an #SASGF Abstract - 2016-09-21
- Need a Dynamic X-Axis with Your SAS Visual Analytics Report? - 2016-07-31
- Planning Your SAS Visual Analytics Dashboard - 2016-06-06