BookmarkSubscribeRSS Feed

Join the Pinball Wizards with SAS

Started ‎03-20-2020 by
Modified ‎08-03-2021 by
Views 3,570
Editor's note: SAS programming concepts in this and other Free Data Friday articles remain useful, but SAS OnDemand for Academics has replaced SAS University Edition as a free e-learning option. Hit the orange button below to start your journey with SAS OnDemand for Academics:

Access Now


Long before video games were invented the most high-tech form of gaming available was the pinball-game-4617526_1920.jpgpinball machine. These machines, with their flashing lights, bells and buzzers entranced generations striving for that elusive high score or free game. Pinball machines survived fierce competition from video games and are still immensely popular with enthusiasts around the world. In this edition of Free Data Friday we will be looking at data from using its API to find detailed information about locations in Las Vegas and which machines are present at each location.


Additionally towards the end of the article you will find some suggestions for further analyses you can do yourself with data from this API. So if you are learning SAS and find you cannot attend your usual place of work or learning as a result of the Covid-19 pandemic then why not install SAS OnDemand for Academics and try some of these? If you hit a problem simply post a question in the appropriate support forum and one of the many experts here will try to help you out.


Get started with SAS OnDemand for Academics

In this 9-minute tutorial, SAS instructor @DomWeatherspoon shows you how to get your data into SAS OnDemand for Academics and other key steps:

Get Started


Get the Data


Instead of a collection of CSV files the pinballmap web site has an extensive API which allows you to download a large selection of data from its web site. The API is fully featured but its documentation is a little sparse so some trial and error was required to decide which call to use and what parameters were required.


Firstly, using Proc HTTP I downloaded JSON formatted data for all regions to discover what region FreeDataFriday_graphic.jpgname I needed to use for Las Vegas data. The JSON library engine allowed me to easily read the output from which I could use Proc SQL to see that the region name I needed was lasvegas. Here is the code I used along with the final output from the Proc SQL call.




filename regs temp; 

proc http 
 method= "GET"

libname regions JSON fileref=regs;

proc sql;
	select *
	from regions.regions
	where state="Nevada";

SQL Results1.png


Then I get information about all the machines in the database


filename macs temp; 

proc http 
 method= "GET"

libname macs JSON fileref=macs;



 Now I retrieve the data for all locations in Las Vegas


filename locs temp;
proc http 
 method= "GET"

libname locs JSON fileref=locs;



In order to find out which machines are in each location I can get a cross reference file – however as you can see that holds machine and location IDs rather than names


filename locmacs temp;
proc http 
 method= "GET"

libname locmacs JSON fileref=locmacs;



Getting the Data Ready


The data required very little preparation after the initial download. I noticed that the location data file contained locations in Las Vegas, Henderson, North Las Vegas and Mesquite. These  are not in the file in error - the lasvegas parameter used in the call refers to a a wider area than just the city of Las Vegas itself. I therefore used Proc SQL to create a subset of the location data containing selected fields and restricted to data from only the city of Las Vegas.


proc sql;
	create table vegaslocs
	as select name as location_name, id as location_id
	from locs.locations
	where city = "Las Vegas";


The Results


In order to produce the detail I require I used Proc SQL to join three tables using the cross reference table to act as the link point for the location and machine names.


proc sql;
	create table vegasmacs
	as select
		a.location_name, as machine_name,
	from vegaslocs a,
		macs.machines b,
		locs.locations_location_machine_xre c
	where and



You can see from the resulting table that I now have a list of every machine at each location along with a brief note about the machines condition.


Ideas for Further Analysis


There is a lot of data available through this API - why not explore it and come up with some analyses of your own? Here are a few ideas to get you started


  • Use Proc SGMap to create a map of all locations in Las Vegas where there are pinball machines;
  • Extract details of all Las Vegas based machines for a selected manufacturer;
  • Find out the average age of machines at each location;
  • Choose 10 machines at random from the machines data set and work out how you could play each machine while visiting the fewest locations


Visit [[this link]] to see all the Free Data Friday articles.


First comment : Thank you 

Version history
Last update:
‎08-03-2021 10:10 AM
Updated by:



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags