Data Analysis Workflow
The Data Analysis Workflow
A data analysis project is not just the moment when statistical software produces results. It is a complete process that begins with an idea and continues through data preparation, analysis, interpretation, writing, revision, and publication or submission as a dissertation or thesis.
A strong workflow allows researchers to know:
- Which data were used
- How the data were changed
- Why particular analytical decisions were made
- When each decision was made
- Who made the changes
- How to reproduce the results later
Without an organized workflow, even careful researchers can lose files, confuse different versions, repeat work unnecessarily, or become unable to explain how a result was produced.
A good data analysis workflow is a planned, documented process that makes research accurate, efficient, transparent, and reproducible.
Why a Workflow Matters
Imagine a researcher who has several files with names such as chapter1_2019.dat and chap1_2019.dat. If the researcher cannot immediately tell which file is newer, what each file contains, or how the files differ, then the project is already vulnerable to errors.
Similar problems arise when:
- A file is accidentally deleted
- Two collaborators work on different versions of the same file
- A researcher cannot identify which data file was used for a particular analysis
- A result cannot be reproduced because the original commands were not saved
- A researcher returns to a project months later and no longer remembers what was done
Analyzing data without a planned workflow is therefore comparable to performing a dangerous activity without the necessary safeguards. Carefulness alone is not enough. A systematic process is needed because small mistakes in data preparation can have major consequences for the final results.
The workflow should be planned rather than developed reactively. An ad hoc workflow is built piecemeal, often in response to mistakes or immediate problems. Such a workflow may seem convenient in the short term, but it makes the overall project difficult to understand and maintain.
A useful way to conceptualize the workflow is:
- Plan
- Organize
- Compute
- Document
These activities are connected rather than strictly separate. Planning influences organization, organization supports computation, and documentation records what happened throughout the process.
The Overall Research Process
A typical social research project may involve the following broad stages:
- Conceiving a research question or idea
- Obtaining or downloading data
- Working with the data on a computer or university network
- Conducting data wrangling
- Performing exploratory data analysis
- Conducting formal statistical analysis or modeling
- Writing up the findings
- Submitting the work for peer review or assessment
- Revising the work
- Publishing the results or submitting a dissertation or thesis
The process is not always linear. Researchers often discover during formal analysis that they need to return to exploratory analysis. They may also realize that the data must be transformed differently, requiring another return to the data-wrangling stage.
Data analysis is better understood as a cycle than as a straight line.
Think About It
If a researcher had to reproduce an analysis performed six months earlier, which parts of the process would be hardest to remember without documentation?
The Audit Trail
An audit trail is a record of the actions taken during a research project. It acts like a line of breadcrumbs leading from the final results back to the original data.
The purpose of an audit trail is not merely to record the final answer. It should show the entire sequence of transformations and decisions that produced the analytical results.
For example, an audit trail should make it possible to identify:
- The original raw data
- The variables selected for analysis
- The cases included or excluded
- Any recoding or transformations performed
- The treatment of missing data
- The statistical procedures used
- The settings and options selected
- The software and package versions involved
- The commands that generated tables, figures, and models
Every action that transforms raw data into an analytical data set should be traceable. This is important because an apparently minor decision can influence every later stage of the analysis.
For example, changing the coding of a variable, excluding a group of cases, or treating missing observations differently may alter descriptive statistics, model estimates, and conclusions. If the action is not recorded, the researcher may be unable to explain why the results differ from another analysis.
Why Drop-Down Menus Create Problems
Many statistical programs provide graphical user interfaces, or GUIs, containing drop-down menus and buttons. These interfaces can be useful for learning or for quickly exploring a data set, but relying on them for serious analysis can create problems.
When commands are selected through menus, the researcher may not retain a complete record of the operations performed. The software may produce an output window, but that output does not always provide a full, clear, and reusable account of the process.
The recommended alternative is to write analysis commands in syntax or code. Depending on the software, this may involve:
- Syntax files in SPSS
.dofiles in Stata- R scripts or R Markdown documents in R
- Python scripts or Jupyter notebooks in Python
Written commands provide several advantages:
- They create a permanent record of the analysis
- They can be rerun after data or decisions change
- They make the sequence of operations visible
- They allow another researcher to inspect the procedure
- They reduce the need to perform repetitive actions manually
- They make it easier to identify and correct errors
The central issue is not that graphical interfaces are always impossible to use. Rather, serious work should be represented in a reproducible form rather than existing only as a series of clicks.
If an analysis cannot be represented clearly in commands or code, it is difficult to audit, repeat, or modify.
Think About It
What would happen if a researcher remembered selecting several options in a menu but could no longer remember the exact order or settings used?
Data Wrangling
After obtaining the data, the researcher usually begins data wrangling. Data wrangling is the process of transforming raw data into a form suitable for analysis.
Raw survey data often contain far more information than a particular research question requires. The data may also use coding schemes, formats, and categories that are not immediately appropriate for the intended analysis.
Selecting Variables
A survey may contain hundreds or thousands of variables, while a particular study may require only a small subset. Selecting variables reduces unnecessary complexity and helps keep the analytical data set focused.
For example, a researcher studying household economic circumstances may need variables measuring income, employment, household composition, and education, but not every variable collected in the survey.
The selection should be recorded because it establishes the boundary of the analysis. Without a record, it may be difficult to determine whether an important variable was intentionally excluded or accidentally overlooked.
Operationalizing Measures
A concept in a research question often has several possible measurements. Operationalization means deciding how an abstract concept will be represented using available data.
For example, “income” might refer to:
- Net individual income
- Gross individual income
- Household income
- Net household income
- Income measured at a particular time
The appropriate measure depends on the research question. A study about an individual’s disposable resources may require net individual income, while a study about household living standards may require household income.
Operationalization is therefore not simply a technical step. It connects the theoretical concept to the specific variable used in the analysis. The decision should be documented because different operationalizations may lead to different conclusions.
Recoding Variables
Recoding means changing the values or categories of a variable into a format required for analysis.
A researcher might recode a variable by:
- Combining several categories
- Creating a binary indicator
- Changing numerical codes into meaningful labels
- Grouping continuous values into categories
- Reversing the direction of a scale
- Creating a new variable from existing information
For example, several education categories might be combined into broader groups if the original categories are too detailed for the intended analysis.
Every recode should be recorded, including the original values, the new values, and the reason for the change.
Selecting Cases
Researchers often analyze only a subset of the available cases. Case selection means specifying which individuals, households, organizations, or observations are included.
Examples include selecting:
- Married couples
- Households with particular characteristics
- Members of a particular age group
- Respondents from a particular ethnic minority background
- Cases observed during a particular survey wave
Case selection directly affects the population to which the results apply. It must therefore be documented clearly. A model based only on married couples should not be interpreted as if it represented the entire population.
Handling Missing Data
Almost every data set contains missing information. A respondent may have declined to answer, may not have been asked a question, or may have provided an unusable response.
The researcher must decide how missing data will be handled. This might involve examining the amount and pattern of missingness and then selecting an appropriate approach.
The important point is that missing-data decisions are part of the analysis, not minor housekeeping. Different treatments can produce different samples and results. The selected approach should therefore be recorded in the audit trail.
Think About It
If two researchers use the same survey but include different cases and treat missing values differently, should their results necessarily be identical? The answer is no: data-wrangling decisions can change the analytical data set before formal modeling even begins.
Exploratory and Formal Analysis
Once the raw data have been transformed into an analytical data set, the researcher usually begins exploratory data analysis. This stage is used to understand the data before applying formal statistical models.
Exploratory analysis may reveal:
- Unexpected patterns
- Unusual values
- Errors in coding
- Differences between groups
- The distribution of variables
- Relationships that require further investigation
- Problems that suggest the data need to be wrangled again
Exploration helps the researcher understand what the data contain and whether the planned analysis is sensible.
The next stage is often formal statistical analysis, such as statistical modeling. Formal analysis uses specified methods to estimate relationships, compare groups, or evaluate hypotheses.
However, exploratory and formal analysis should not be treated as completely separate stages. A formal model may reveal a problem that was not visible earlier. The researcher may then need to return to exploratory analysis or revise the data-wrangling process.
This iterative movement is normal. A careful workflow allows the researcher to move backward without losing track of previous versions or decisions.
Decisions That Must Be Documented During Analysis
Many analytical decisions are easy to overlook because they may be controlled by default settings in statistical software. Nevertheless, these choices can affect the results and should be included in the audit trail.
Case Selection
The analysis file should show which observations were used. Exclusions should be explicit rather than hidden in a temporary command or forgotten filter.
Variable Formats
The format of a variable can influence how software interprets it. Researchers should record decisions about variable types, coding, labels, and transformations.
Missing-Data Treatment
The analysis should state how missing observations were treated and whether different procedures used different samples.
Estimation Method
Statistical models may allow different estimation methods. Examples include:
- Maximum likelihood estimation
- Generalized least squares
The chosen method should be recorded because the estimation procedure is part of the model specification.
Weights and Survey Structure
Survey data may require weights or adjustments that reflect how the sample was designed. Researchers may need to decide which weights to use and how to represent features such as clustering, stratification, or other aspects of the survey structure.
These decisions affect how the results represent the target population and how uncertainty is estimated.
Random Procedures and Seeds
Some methods involve random-number generation, such as bootstrapping. A bootstrap repeatedly resamples the observed data to study the variability of an estimate.
Because random procedures can produce different results on different runs, researchers should set and record a random seed. A seed allows the same sequence of pseudorandom numbers to be generated again, making the analysis more reproducible.
Model-Specific Settings
Some models require additional technical decisions. For example, a random-effects model may use numerical integration and require a choice about the number of quadrature points.
The researcher may need to determine whether the software’s standard or default number is sufficient or whether a different number is appropriate. Even if the software supplies a default, the setting remains part of the analysis and should be documented.
Software and Package Versions
In R or Python, a particular procedure may depend on the library or package selected. Results may also vary if the package or software version changes.
A reproducible record should therefore identify:
- The software used
- The relevant package or library
- The version of the software or package
- Important options or settings
These details may seem technical, but they can explain why another researcher obtains a different result while using apparently similar commands.
Think About It
Why might a default software setting still need to be documented? A default is still an analytical choice because it determines how the software performs the procedure.
The Four Pillars of a Good Workflow
A planned workflow provides four major benefits: accuracy, programming efficiency, transparency, and reproducibility.
Accuracy
Accuracy means minimizing information loss and errors in the analysis and its outputs.
A systematic workflow improves accuracy by reducing opportunities for:
- Selecting the wrong file
- Applying a transformation inconsistently
- Forgetting a step
- Copying results incorrectly
- Using the wrong sample
- Confusing versions of variables or data sets
Accuracy does not mean that errors become impossible. It means that the workflow makes errors less likely and easier to identify.
Programming Efficiency
Programming efficiency means using the capabilities of statistical software or programming languages to reduce unnecessary manual work.
For example, if the same operation must be performed on ten waves of data, the researcher could write a loop that applies the operation across all ten waves. This is more efficient than manually repeating the same action ten times.
Automation also improves consistency. A command repeated by software is less likely to vary accidentally than a task repeated manually.
Transparency
Transparency means making it possible to show:
- What was done
- Why it was done
- When it was done
- How it was done
Transparency allows collaborators, reviewers, supervisors, and future readers to understand the reasoning behind the analysis. It also helps the original researcher remember the project later.
Reproducibility
Reproducibility means that the same analysis can be carried out again and produce the same result, regardless of who performs it or which suitable computing environment is used.
For example, an analysis should ideally produce the same results when run on a researcher’s laptop and on a university network machine, assuming the relevant data, code, software, and settings are equivalent.
Reproducibility becomes especially valuable when:
- A thesis chapter must be rewritten
- New analyses are required
- A journal referee requests revisions
- A collaborator needs to inspect the work
- The analysis is extended to another data wave
- A result must be checked months or years later
Documentation is easiest to write while the work is being performed, not after memory of the work has faded.
Documentation and Comments
Researchers often postpone documentation because it seems less urgent than analysis. A common situation occurs near the end of a workday: the researcher saves the file and intends to add comments later. When the researcher returns, new messages, meetings, and other responsibilities may make the documentation easy to forget.
The result is a file containing commands but little explanation. The commands may show what happened, but not why it happened.
Comments should therefore be written during the work. They do not need to be elegant or lengthy. Even brief comments can preserve essential context, such as:
- The purpose of a section of code
- The reason for excluding cases
- The meaning of a recoded variable
- The source of a data file
- The date of an update
- A problem that still needs attention
- The next action required
Comments provide narrative around the technical commands. They turn a sequence of instructions into an understandable account of the research process.
A useful analysis file can begin with a header containing:
- The researcher’s name
- The project name
- The relevant subproject
- The date of the next meeting or supervision
- The date of the latest update
- A record of previous updates
- The next actions to be completed
The next actions should appear near the top rather than after hundreds or thousands of lines of code. This allows the researcher to understand the current state of the project immediately upon opening the file.
Documentation may feel like an additional burden, but researchers rarely regret having written it. In contrast, researchers frequently regret not recording a decision when they can no longer reconstruct it.
Think About It
Which would be more useful after a long break from a project: a file containing only commands, or a file containing commands alongside explanations of purpose, decisions, and next steps?
Designing a Practical Directory Structure
A directory structure organizes project files into predictable locations. A standard structure reduces the time spent searching and lowers the chance of using the wrong file.
A project may include folders for:
- Raw data: Original files that have not been changed
- Clean data: Data sets prepared for analysis
- Codebooks: Documentation describing variables and coding
- Syntax or scripts: Commands used for data wrangling and analysis
- Documents: Reports, drafts, and written materials
- Figures: Graphs and visual outputs
- Logs: Records of software output or analysis runs
- Tables: Tables produced for reports or publications
- Temporary files: Files used during intermediate operations such as merging
- Trash: Files no longer needed but retained temporarily
- Working files: Materials currently being developed before being placed in a more permanent location
The exact structure can be adapted to the researcher’s preferences. The important principle is consistency. A directory system should support the way the researcher works rather than impose a rigid structure that will not be maintained.
Raw data should be protected from accidental alteration. Transformations should normally create new analytical or clean data files rather than overwriting the original data.
File-Naming Conventions and Version Control
A file name should communicate enough information to identify the file without opening it. A useful convention can include:
- An eye-readable project or data name
- The date
- The depositor’s or researcher’s initials
- The version number
- The file type or extension
For example, a file name based on a household panel data set might identify:
- The study
- The survey wave
- The type of response file
- The date
- The person or organization responsible for the file
- The version
- The file format
A date written in year-month-day order is particularly useful because files sort chronologically when listed alphabetically. This is more informative than placing only a year at the end of a file name, especially when many files are created over several years.
Version control means keeping track of the different stages or editions of a file. Version numbers such as v1, v2, and later versions help researchers determine which file is most recent and how files differ.
Version control is especially important in long projects. A researcher may need to locate a data file created during the first year of a doctoral project several years later. A clear naming system reduces the time, anxiety, and uncertainty involved in finding it.
Variable-Naming Protocols
Good data providers often use clear and systematic variable names. These names may encode information such as:
- The survey wave
- The time point
- The topic
- The type of measure
- The question or item represented
For example, a variable name may indicate that it measures sex or gender in a particular survey wave. Another name may identify the type of school attended at a particular point in a longitudinal study.
Such names are eye-readable, meaning that a researcher can make a reasonable interpretation from the name itself.
However, not all data sets use readable naming conventions. Some variables have opaque names such as a short combination of letters and numbers. In those cases, the name alone does not reveal the meaning of the variable.
When variable names are unclear, researchers should use codebooks and other data documentation, then create their own labels, notes, or documentation to clarify the meaning. A project’s variable-naming protocol should be designed so that new variables can be understood consistently.
A useful naming system should help identify:
- What the variable measures
- Which wave or time point it belongs to
- Whether it is original or derived
- What coding or transformation it contains
Estimating How Long Data Work Takes
Data wrangling and data analysis often take much longer than initially expected. A useful planning rule is that a task may take roughly five times longer than the first estimate, even when the researcher has a good workflow.
For example:
- A task estimated at one hour may require about five hours
- A task estimated at one day may require about five days
- A task estimated at one week may require about five weeks
This is not a precise law, but it is a practical warning against underestimating the time needed for data work.
The reason is that analysis includes more than the central command. Time may also be needed for:
- Finding and understanding the data
- Reading documentation
- Checking variable coding
- Resolving errors
- Testing commands
- Inspecting unexpected results
- Documenting decisions
- Revising the analysis
- Preparing outputs
The estimate is also important when planning supervision, grant proposals, consultancy work, and project budgets. A poor workflow may make the task take even longer, whereas a good workflow helps keep the work closer to a realistic estimate.
Benefits of a Good Workflow
A good workflow has benefits beyond organization.
Reduced Duplication of Effort
Once a researcher has analyzed one wave of a panel study using well-documented code, the same workflow can often be adapted for later waves. The researcher does not need to recreate every step manually.
Fewer Errors
Systematic work reduces the likelihood of accidental inconsistencies. When the same commands are used repeatedly, the process is more reliable than manually reproducing the same operations.
Easier Error Detection
A documented sequence allows the researcher to identify where a problem occurred. If an output appears unusual, the researcher can inspect the relevant data transformation or analytical command.
Easier Editing and Revision
Research outputs often undergo revision. A thesis chapter may need to be rewritten, or journal reviewers may request additional analyses. A good workflow allows the researcher to return to the project quickly and make changes without reconstructing the entire analysis.
Better Collaboration
In collaborative or interdisciplinary projects, a clear workflow allows each person to understand the work performed by others. Collaborators can inspect commands, modify parts of the analysis, and add new work without creating confusion.
This is particularly important when team members work in different institutions, countries, or disciplinary traditions.
Support for Future Research
A well-documented project supports later work that builds on the original analysis. The researcher’s future self is effectively another collaborator who needs to understand the earlier decisions.
The workflow therefore preserves not only the results but also the knowledge required to extend them.
Making the Workflow Sustainable
An effective workflow should support the researcher’s actual working habits. It should not be so rigid or complicated that the researcher cannot maintain it.
The goal is not to impose an extreme, inflexible system. The goal is to create a practical structure that can be followed consistently.
A researcher can improve the workflow incrementally by:
- Creating a standard directory structure
- Protecting raw data from alteration
- Writing commands instead of relying only on menu selections
- Establishing file and variable naming conventions
- Using version numbers
- Recording software and package versions
- Writing comments while working
- Keeping next actions visible
- Planning the sequence of work
- Reviewing whether every important decision can be traced
Improvement does not require rebuilding every previous project. A researcher can begin with the next project or the next major task. Early-career researchers may find this especially useful because good habits can be established from the beginning.
Think About It
Which single change would most improve an existing project: better file names, a clearer directory structure, written syntax, or more detailed comments? The best answer depends on where the project is currently most vulnerable.
Comprehensive Review
The data analysis workflow covers the entire research process, from the initial idea to the final publication, thesis, or dissertation. It includes data acquisition, data wrangling, exploratory analysis, formal modeling, writing, revision, and dissemination.
The central principles are:
- Plan rather than improvise. An ad hoc workflow makes errors and confusion more likely.
- Keep an audit trail. Every transformation and analytical decision should be traceable.
- Write commands or code. Written syntax is more reproducible than relying only on graphical menus.
- Document data wrangling. Variable selection, operationalization, recoding, case selection, and missing-data treatment all affect results.
- Document analytical settings. Estimation methods, weights, survey structures, random seeds, model settings, software, and package versions matter.
- Organize files systematically. Separate raw data, clean data, code, outputs, documents, temporary files, and other materials.
- Use meaningful names and versions. File names and variable names should help researchers identify what materials contain and when they were created.
- Write comments immediately. Documentation created today is more reliable than documentation reconstructed later.
- Use automation where appropriate. Loops and reusable code improve efficiency and consistency.
- Build a sustainable system. The workflow should support the researcher’s actual work habits.
- Expect analysis to take time. Data work commonly takes far longer than the initial estimate.
- Help the future researcher. A clear workflow makes revision, collaboration, replication, and later research much easier.
A rigorous workflow ultimately connects raw data to published conclusions through a visible chain of decisions. That chain is what makes serious data analysis accurate, transparent, efficient, and reproducible.

Ask anything
We've read this whole study set, so questions about it get the best answers.