Preparing Data for Analysis is (more than) Half the Battle

by Karen Grace-Martin

Just last week, a colleague mentioned that while he does a lot of study design these days, he no longer does much data analysis. 

His main reason was that 80% of the work in data analysis is preparing the data for analysis.  Data preparation is s-l-o-w and he found that few colleagues and clients understood this.

Consequently, he was running into expectations that he should analyze a raw data set in an hour or so.

You know, by clicking a few buttons.

I see this as well with clients new to data analysis.  While they know it will take longer than an hour, they still have unrealistic expectations about how long it takes. 

So I am here to tell you, the time-consuming part is preparing the data.  Weeks or months is a realistic time frame.  Hours is not.

(Feel free to send this to your colleagues who want instant results).

There are three parts to preparing data: cleaning it, creating necessary variables, and formatting all variables.

Data Cleaning

Data cleaning means finding and eliminating errors in the data.  How you approach it depends on how large the data set is, but the kinds of things you’re looking for are:

  • Impossible or otherwise incorrect values for specific variables
  • Cases in the data who met exclusion criteria and shouldn’t be in the study
  • Duplicate cases
  • Missing data and outliers
  • Skip-pattern or logic breakdowns

You can’t avoid data cleaning and it always takes a while, but there are ways to make it more efficient. 

For example, one way to find impossible values for a variable is to print out data for cases outside a normal range.

This is where learning how to code in your statistical software of choice really helps.  You’ll need to subset your data using IF statements to find those impossible values.

But if your data set is anything but small, you can also save yourself a lot of time, code, and errors by incorporating efficiencies like loops and macros so that you can perform some of these checks on many variables at once.

Creating New Variables

Once the data are free of errors, you need set up the variables that will directly answer your research questions. 

It’s a rare data set in which every variable you need is measured directly.

So you may need to do a lot of recoding and computing of variables. 

Examples include:

  • Creating change scores
  • Creating indices from scales
  • Combining too-small-to-use categories of nominal variables
  • Centering predictors
  • Restructuring data from wide format to long (or the reverse)

Formatting the Variables

Both original and newly created variables need to be formatted correctly for two reasons:

First, so your software works with them correctly.  Failing to format a missing value code or a dummy variable correctly will have major consequences for your data analysis.

Second, it’s much faster to run the analyses and interpret results if you don’t have to keep looking up which variable Q156 is.

Examples include:

  • Setting all missing data codes so missing data are treated as such
  • Formatting date variables as dates, numerical variables as numbers, etc.
  • Labeling all variables and categorical values so you don’t have to keep looking them up

All three of these steps require a solid knowledge of how to use your statistical software.  Each one approaches them a little differently. 

It’s also very important to keep track of and be able to easily redo all your steps.  Always assume you’ll have to redo something.  So use (or record) syntax, not menus.

{ 1 comment… read it below or add one }

Richard

I agree very much.

As a Psychologist the data of my experiments are comparingly small. But still, doing the actual statistical analysis does not take up so much time. Getting your data in shape to do any reasonable and valid analyses does.

Tidying your dataset and creating variables really takes around ~ 80% of the time you spend with it. And it’s not like you tidy it and then it’s done. Most times you come up with another interesting way to get some insights with your data but then you find out that you have to create another variable for this calculation and it’s back to tidying data and creating variables.

Reply

Leave a Comment

Please note that, due to the large number of comments submitted, any comments on problems related to a personal study/project will not be answered. We suggest joining Statistically Speaking, where you have access to answers and more resources 24/7.

Previous post:

Next post: