BI Tools

Tips and tricks for building information maps, OLAP cubes, reports, and dashboards

BI Admin

Learn your way around a SAS BI installation.

Visual Analytics

Learn your way around the SAS Visual Analytics tool

Coding & Data

Extract, transform, and load your data into the SAS BI toolset

Stored Processes

Create and design stored processes like a rock star

Home » Enterprise Guide

SAS Enterprise Guide: Pick a Winner Randomly

Submitted by on 2012-04-17 – 7:29 AM 10 Comments

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

sas stored process book winners

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!

You can purchase your copy of The 50 Keys to Learning SAS Stored Processes from this site or from Amazon!  We can’t wait to hear your reviews!


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.
The following two tabs change content below.

Tricia Aanderud

Director of Data Visualization at Zencos Consulting
Tricia Aanderud is a SAS Business Intelligence and Visual Analytics consultant based in Raleigh, NC who works for Zencos Consulting. She has written several books about SAS, presented papers at many SAS conferences, and has been using SAS since 2001. Contact her for assistance with your next project.
Spread the love

Tags: , ,


1 Pingbacks »