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)
- Seven Interesting Data Storytelling Examples - 2018-06-09
- Use Network Analysis to Understand Your Customers with SAS Visual Analytics 8.2 - 2018-01-21
- My 7 Favorite Features in SAS Visual Analytics 8.2 on Viya - 2018-01-14
- Designing Dashboards: Finding the Fantastic Five Colors - 2017-06-19
- Creating a Web Analytics Report in SAS Visual Analytics 8.1 - 2017-06-19