Install any skill in seconds. Free to start, no credit card required.
Get Started Free →brycewang-stanford/stata-data-cleaning
Clean and transform messy data in Stata with reproducible workflows
Passed 24 of 25 test cases with the skill, and 20 of 25 without it.
and 2 more in the full report
4 fixed20 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 4 test cases the skill fixed. Same model, same prompt, with and without the skill.
In Stata, you have a phone number string variable 'phone_str' formatted with symbols like '(555) 019-2831'. Write a Stata command to strip away all non-numeric characters using regular expressions.
| Checked | Without skill | With skill |
|---|---|---|
| Uses ustrregexra to perform regular expression replacement. | Passed | Passed |
| Employs the regex pattern [^0-9] to match non-digit characters. | Missed | Passed |
The instructions your model reads when the skill loads.
Clean, transform, and validate messy research datasets in Stata. This skill covers the complete data preparation pipeline from raw survey or administrative data to analysis-ready datasets, with emphasis on documentation, reproducibility, and handling the common data quality issues encountered in social science, economics, and health research.
Data cleaning typically consumes 60-80% of research time in empirical studies, yet it is often under-documented and poorly reproducible. Stata provides a powerful set of commands for data manipulation, but knowing which commands to use and in what order requires experience with common data quality issues: inconsistent coding, duplicate observations, string formatting problems, implausible values, and complex missing data patterns.
This skill provides a systematic, step-by-step data cleaning workflow in Stata. Each step produces a log of changes made, enabling full reproducibility and audit trails. The workflow is organized around the principle that raw data should never be modified in place -- instead, cleaning scripts transform raw data into processed datasets while preserving the original.
The approach follows best practices from the World Bank's DIME Analytics team and the J-PAL research transparency guidelines, making it suitable for projects that require rigorous data documentation for peer review, replication packages, or regulatory compliance.
* ============================================
* Data Cleaning Script: [Project Name]
* Author: [Name]
* Date: [Date]
* Input: raw/survey_data_raw.dta
* Output: processed/survey_data_clean.dta
* ============================================
clear all
set more off
log using "logs/cleaning_log.smcl", replace
* Load raw data
use "raw/survey_data_raw.dta", clear
* Basic inspection
describe
summarize
codebook, compact
* Check dimensions
display "Observations: " _N
display "Variables: " c(k)
test cases passed, vs 20 / 25 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.