Packing The Stands at Nationals Park

Bryce Harper’s two home runs and Stephen Strasburg’s seven scoreless innings rightly earned the headlines in Monday’s opening-day win for the Washington Nationals. But the data journalist in me couldn’t help but want to apply a little percent change action to the proceedings.

So, I did, especially after I noticed in the boxscore that Nationals Park, on a Monday, was jammed to 108% capacity. A few minutes of research and Excel later, I had some findings:

  • The Nats’ opening day attendance of 45,274 was 11% higher than the team drew at last year’s home opener, when they beat the Reds 3-2 in 10 innings.
  • The attendance wasn’t a record for Nationals Park, but it was close — about 700 below the record set on the last, heartbreaking (if you’re a Nats fan) game of the 2012 NL division series against the St. Louis Cardinals.
  • The day was, however, a regular-season record for the park, which opened in 2008.

After I figured this out, I went a-Googling to see if anyone else had the same scoop. Didn’t find the percent change, but I did see a mention of the attendance record in a post on We Love DC and a mention on a MASN Sports blog that didn’t qualify it against the post-season record. Nothing from major sports media (please comment below if I missed some).

I’m not about to play a baseball writer — it’s one of the few jobs I haven’t had in journalism — but the basics of ballpark attendance gets too little attention, I think. And yet the money flowing through the turnstiles means a lot for a team and a city, as does the mental boost for the players who hear the cheers.

Can the Nats keep it up? I’ll be watching this chart at


Excel: Extract text with FIND and MID

Data analysis begins with usable data, and that means every piece organized nicely into its own field where we can count, sort and otherwise test it out.

What if you get a spreadsheet where the pieces of data are all packed in one field? Say, something like this (which I cobbled together from Major League Baseball data in honor of the Nationals’ first playoff appearance):

NAME: Sean Burnett POS: RP AGE: 30 WT: 200 BORN: Dunedin, FL SALARY: 2350000
NAME: Tyler Clippard POS: RP AGE: 27 WT: 200 BORN: Lexington, KY SALARY: 1650000
NAME: Ross Detwiler POS: SP AGE: 26 WT: 174 BORN: St. Louis, MO SALARY: 485000
NAME: Christian Garcia POS: RP AGE: 27 WT: 215 BORN: Miami, FL SALARY: N/A
NAME: Gio Gonzalez POS: SP AGE: 27 WT: 205 BORN: Hialeah, FL SALARY: 3335000
NAME: Mike Gonzalez POS: RP AGE: 34 WT: 215 BORN: Robstown, TX SALARY: N/A
NAME: Ryan Mattheus POS: RP AGE: 28 WT: 215 BORN: Sacramento, CA SALARY: 481000
NAME: Craig Stammen POS: RP AGE: 28 WT: 200 BORN: Coldwater, OH SALARY: 485000
NAME: Drew Storen POS: RP AGE: 25 WT: 180 BORN: Indianapolis, IN SALARY: 498750
NAME: Jordan Zimmermann POS: SP AGE: 26 WT: 218 BORN: Auburndale, WI SALARY: 2300000

Let’s say you want to extract the city of each player’s birth into a separate field. The varying length of each player’s name means the birth place isn’t always in the same position in the string, so a typical text-to-columns operation won’t work. So, how to do it?

The answer lies in two very handy Excel functions: FIND and MID.

FIND locates characters you specify and returns its numeric place in the string.

MID returns X characters from a string beginning at a location X you specify.

For example, we can locate the position where each city name begins by using FIND to locate the string “BORN:” in each cell. The city name itself always starts six characters after the position of that string, so we add six to the result:


In the first row above, the functions returns 50. In the second row, 52. We’ll feed that value to the MID function as the starting point for our extraction.

MID takes three arguments: Text or cell, position to start, number of characters to return. So, we use the above FIND function as the second argument and, for now, extract 10 characters:


That gets us part of the way there. We’re starting in the right spot, but 10 characters isn’t always the length of the city and state, so it leads to choppy results:

Dunedin, F
St. Louis,
Miami, FL 
Hialeah, F

What we need to do is tell MID the exact number of characters to return each time even though the length of the city varies. We can figure this out using FIND again.

Which web browsers do journalists favor?

After I started playing with Internet Explorer 9 tonight — and knowing that most developers, including Microsoft, want to wean the world from IE6 as soon as possible — I grew curious about the browsers favored by my site’s visitors. A quick dig into Google Analytics gave me the data for the last few months, and the Google Charts API let me build a quick pie:

Site visits by browser, November 2010-March 2011

I can’t know for sure, but I suspect that most people who read my site are journalists or developers. Most traffic comes from links I post on Twitter or via search keywords that tend toward journalism, data, math and, lately, the Census.

Generally, you’re not an IE-centric crowd — just 12%. That’s lower than overall metrics, which tend to place Internet Explorer at anywhere from 40% or more of the overall market.

Oh, and the percent using IE6? Less than 0.4%.

Story hunting in birth, death data

Note to readers: This post, originally published in 2010, is being updated regularly. It currently reflects final 2014 U.S. birth data available as of December 2015.

* * *

The U.S. government’s annual count of births and deaths is among the most basic of demographics, but tracking it is one of my little obsessions. I keep annual totals in a spreadsheet and get all gooey inside when I can add another year to the pile.

In December 2015, for example, the National Center for Health Statistics released data showing that the number of births in the U.S. rose in 2014, the first increase since 2007. In my mind, a yearly change like that in a longitudinal data set certainly is worth covering.

But sometimes these basic demographics — including Census data — reveal even more when we take a long-term view.

For example, below are the annual number of births and deaths from 1933 to 2014 plotted via the Google Charts API. Hover over the lines for the data:

It’s simple — just two fever lines. But it’s chock full of generational milestones that bear watching:

  • The first baby boomers — those born in 1946 — are turning 70 in 2016.
  • The Gen Xers that follow are marching toward middle age, now in their mid 30s to early 50s. (Gen X poster boy Eddie Vedder of Pearl Jam hit the half-century mark in 2014.)
  • Meanwhile, the first of the Millennials — the “echo boomers” whose numbers peaked in 1990 — are in their early 30s.

Each generation brings a new sensibility to the stages of life, and the relative size and makeup of each group — not to mention its cultural context — gives journalists plenty of opportunity for storytelling. Two examples:

  • Much has been written about the big bump of post-World War II babies marching closer to retirement (maybe), Social Security, and the years where health care becomes a major concern. But what about the inevitable? Notice that the number of deaths in the U.S. has ticked up to about 2.6 million a year. Expect that to keep climbing as more Boomers head into the years where death rates rise dramatically. How will 4 million deaths annually affect the funeral home business, the ability to buy a cemetary plot, and the overall industry around end-of-life care?
  • Along with Gen X came the “baby bust,” the years of rapidly declining birth rates that led to all kinds of prognostications about the shrinking of America. That means our workforce now has a relative shortage of thirty- and forty-somethings. Does that mean more opportunity for Millennials to advance in the business world and less pressure for boomers to retire?

These sorts of trends are slow-burning, but they reflect data trends that exert hidden but massive force on our culture, much like the tides. The savvy data journalist keeps an eye on them not just for what they say this year but what they reveal over time.

Sorting Data in Excel: Simple Analysis

Sorting a data set helps answer a basic question journalists like to ask: “Which ____ has the highest (or lowest) ______?”

Excel (and other spreadsheets such as the open source Calc) make sorting data easy. In fact, I often make sorting my first step when “interviewing” data because it quickly reveals high and low values and often highlights some that may seem questionable.

Let’s work through a simple sort in Excel. I’ll be using Excel 2007, but older versions have similar functions. Start by downloading the file “sorting.xls” and saving it to your computer. Open it and follow along:

1. We have a table of Census data from the 2006-2008 American Community Survey. It shows the median age of the population for each of 79 school districts in Virginia plus the state itself.

We want to know which district has the oldest and youngest populations. Let’s sort it!

2. Click once on one cell anywhere in the table. This will help Excel auto-discover your table in the next step.