RESEARCH SUPPORT
Stata Data Management for Research
Data Prepared Before Any Model Is Run
Cleaning, labeling, reshaping and merging in Stata, written as a do-file that starts at your raw data and ends at an analysis-ready file, with every change to the sample counted and explained.
No Commitment Required
Strictly Confidential
In-House PhD-Level Statisticians
Fixed Project Fee
Same-Day Response
What Does Stata Data Management Involve?
Stata data management is the work between the raw files and the first model: checking and correcting variables, labeling them, combining files and changing their layout so that the unit of analysis matches the research question. Its quality decides what every later estimate means, because a faulty merge or a silently dropped record changes the sample without any error message. OnlineSPSS, a specialist statistical consultancy for academic, clinical and professional research, provides this support: an in-house PhD-level statistician writes the preparation as a do-file that runs from the source data and documents each rule, so that you can check it against your codebook. The design of the study, and what the prepared data are used to conclude, stay with you.
WHEN TO ENGAGE
Data Situations That Call for Careful Preparation First
Preparation requests tend to arrive with raw files from several sources or waves, before anyone has fitted a model.
Several Files, One Analysis Survey waves, registry extracts or administrative files must be combined, and the keys, the match results and the resulting sample need to be examined before analysis.
Wide Data, Long Model Repeated measures sit in one row per participant, and the model needs one row per participant and occasion, or the reverse, with names and labels carried across.
Raw Export With Quirks A survey platform or database export arrives with numbers stored as text, mixed date formats and codes for refused answers, which must be converted under written rules.
Inherited Cleaning Code A cleaning do-file from a previous researcher or coauthor exists, and nobody can say what it drops or recodes, so it is read, annotated and rerun against the raw data.
WHAT THE PREPARATION COVERS
Preparation Steps From Raw File to Analysis-Ready Data
Stata data cleaning is a sequence of decisions, each written into the do-file as a rule that a coauthor can read and rerun.
Inspecting the Raw Data
As the first stage of Quantitative Data Analysis, variable types, ranges and impossible values are examined, with logic checks written as assertions so that a failed check stops the run.
Cleaning Rules
Each recode, correction and exclusion is a documented rule with its reason and the number of records it affects, so that nothing alters the sample unnoticed.
Labels and Codebook
Variables and values are labeled and the codebook is written to match, so that a coauthor can read the dataset without the original questionnaire beside them.
Combining Files
A merge starts from the unit of analysis and the key on each side, with the match result tabulated and explained, and appended files are checked for variables stored differently across waves.
Reshaping Wide and Long
Stata reshape and merge decisions go together, since the layout a model needs sets how repeated measures are stacked, as in Panel Data Analysis (Fixed & Random Effects).
Missing Values in the Open
Codes such as 99 for refused or 9 for not applicable become missing, the amount and pattern of missingness are tabulated, and any treatment beyond complete cases is planned under Missing Data Analysis.
COMMON DATA ISSUES
Preparation Errors That Change Results Without a Warning
Preparation faults rarely stop a do-file, so they surface later as odd estimates, and the six below are the ones looked for deliberately.
Numbers Stored as Text An export stores 12.5 as text, or a stray character turns a column into a string, so conversion follows a rule and the cases that fail to convert are inspected, not blanked.
Dates in Mixed Formats Day-month and month-day entries share a column, and a date that converts to the wrong year shifts every follow-up time, so the format of each source is established first.
Reshape That Stops or Misleads Reshaping to wide stops with an error when a variable that should be constant within a person varies, and forcing past it hides a data problem, so the cause is traced instead.
Merge Results Left Unread Records from either file that found no match stay in the merged file with missing values and drop out of later models unnoticed, so the match counts are checked before analysis.
Labels That Differ Across Files Appending files whose value labels differ can leave a code carrying the label of the first file, so the labels of every source are compared before the files are stacked.
Exclusions Without a Count Cases are dropped as outliers or incomplete without a record of how many, so the final sample cannot be reconciled with the one in the methods, and each step reports its count.
DELIVERABLES
What the Preparation Hands Back to You
Together the items let the sample in your methods section be traced back to the raw files, one step at a time.
Cleaning Do-File A do-file that starts at the raw data and produces the analysis-ready file in one run, with comments that explain each rule.
Sample Flow Record The number of records and variables after each major step, so that the sample described in your methods can be reconciled with what you received.
Labeled Analysis File A cleaned .dta file with variable and value labels, formats applied and missing values standardized across variables.
Variable Codebook A codebook listing each variable with its source, its coding, the rules for derived variables and its missing-value codes.
Merge and Reshape Report The merge result tables, the keys used and the reasoning for each reshape, kept as a short document for your methods or supplement.
Rerun Instructions Notes on the order in which the files run and where they expect the data, so that a coauthor or supervisor can reproduce the prepared data.
ILLUSTRATIVE EXAMPLE
Three Survey Waves Merged Into One Analysis File
An illustration of how separate wave files and a regional price file become one household-by-wave dataset.
ILLUSTRATIVE EXAMPLE · HOUSEHOLD PANEL SURVEY RESEARCH · UNITED STATES
A doctoral researcher in sociology wanted to follow household food spending across three survey waves, with each wave delivered as a separate file and a regional price file to be added.
The unit of analysis was fixed as the household-wave before any cleaning began. The second wave stored income as text and the third used 99 for refused answers, so both were converted under written rules, and the three wide files were reshaped to one household-by-wave file. The complication appeared at the merge with the regional file, which was keyed on region and year: households that had moved between waves had carried their old region forward, so they matched the wrong price record. The region of each household was re-derived for every wave, the merge was repeated on region and wave, and the unmatched households were traced to a region code that had been relabeled. The count of households was reported after every step.
Outcome: The researcher received the cleaning do-file, the record of counts after each step, a labeled long-format .dta file, a codebook and a short note on the merge.
This example does not describe a real client or project. We never share details of actual client work, in line with the confidentiality we promise every researcher. This illustrative example is included to show the type, scope, and standard of work involved in this kind of analysis.
SOFTWARE
Tools Beside Stata for the Same Preparation
The preparation described here is written in Stata, and the same rules can be carried into another environment when a team's pipeline requires it.
HOW WE ASSESS YOUR PROJECT
We Review Your Actual Research
Your assessment is based on a review of your actual research materials and analytical requirements, not a generic project category.
You Submit Your Project Details
Share whatever is available at the current stage, such as the research aim, protocol or proposal, dataset, variable list, manuscript or statistical requirements.
We Review Your Research and Define the Scope
Your statistically trained Research Coordinator reviews the materials to understand the study design, research questions, data structure, analytical requirements and expected deliverables. If clarification is needed, additional documents or information can be requested before the assessment is finalized.
Your Analysis Is Completed and Delivered
Once the scope and fixed project fee are agreed, the in-house statistician completes the work and the Research Coordinator remains the communication point through delivery, with the analysis, deliverables and timeline as agreed.
RESEARCH RESPONSIBILITY
Statistical Support Within Your Own Research
OnlineSPSS prepares the data to the rules agreed with you, and the study built on them, with its conclusions, remains the researcher's.
Agreed Statistical Support OnlineSPSS provides the agreed methodological, analytical and statistical reporting support, defined in a scope that is confirmed before any work begins.
No Intellectual Contribution OnlineSPSS does not claim any intellectual contribution to your dataset, thesis or article. Authorship remains the researcher's.
Your Research Decisions The research question, the definition of each variable, the discussion of the findings and the conclusions remain yours, with overall responsibility.
Confidential Handling Research data and project details are handled confidentially, project information is not published, and an NDA is available where required.
FREQUENTLY ASKED QUESTIONS
Questions About Data Management in Stata
Most preparation questions concern the layout a model needs, where corrections should live and how the cleaning is reported.
What does data preparation in Stata cover in a research project?
Stata data management at OnlineSPSS covers the cleaning, labeling, merging and reshaping of research data, written as a do-file that runs from the raw files to the analysis-ready dataset. Each rule is documented with its effect on the sample, and the scope is confirmed in the assessment.
When should data be in wide format and when in long format?
The model decides. Many repeated-measures and multilevel models, and the panel commands in Stata, expect long format with one row per person and occasion, whereas some multivariate and change-score analyses use wide format with one row per person. A reshape can be reversed as long as the identifiers are unique, so each analysis can use the form it needs while the raw files stay untouched.
Should errors be corrected in the dataset or in the do-file?
In the do-file. The raw files are kept unchanged and each correction is a line of code with its reason, so the cleaning can be inspected, reversed and rerun. A value typed over in the Data Editor is not part of the do-file, so the correction is lost the next time the data are rebuilt from the raw files, and where a value is corrected from a source record, the source is cited in a comment.
How should data cleaning be reported in a methods section?
Report the sample at each stage: the records received, the records excluded with the reason for each rule, the final analytic sample and how missing values were handled. A short flow description or table does this, and the do-file serves as the detailed record. Where a reporting guideline applies, such as STROBE for observational studies, it also sets expectations for describing participant flow.
How do you protect my research data and confidentiality?
Your data and project details are handled confidentially, and project information is not published. Researcher names and institutions are not used publicly without permission. An NDA is available where required and can be arranged before sensitive materials are shared. Read more about confidentiality and data security.
What happens when I request an assessment, and how long does it take?
You share your research question, design and relevant materials, such as the raw files, the questionnaire or codebook and any existing do-files, and a statistically trained Research Coordinator reviews the request and responds the same day. The analysis, deliverables, timeline and one fixed project fee are then confirmed before any work begins, so the timeline follows from the agreed scope.
Still have a question? Find more answers in our full FAQ.
NEXT STEP
Prepare Your Raw Files
for Analysis
A list of the source files, the questionnaire or codebook and a note on the unit of analysis you intend are enough for the assessment to size the preparation.
No Commitment Required
Strictly Confidential
Fixed Project Fee
In-House PhD-Level Statisticians
Same-Day Response
Serving Researchers Since 2014