04.04Data PreparationAvailable

Data Transformation and Dataset Preparation

Builds the analysis-ready file: recodes, derived variables, nets, bands, merges and wave stacks, each documented, verified against source, and captured in a codebook.

Free. Works on Claude, ChatGPT, Gemini or any assistant that accepts a skill file.

What this skill does

The method, encoded.

Transformation is where the shape of the answer gets decided. A five-band age variable becomes three. A satisfaction scale is reversed to match a tracker. A net of "any negative experience" appears. Spend is banded into quartiles. An index is built from eight items, two of which were negatively worded. Two files are merged on a customer ID. Every one of these is legitimate, and every one creates something nobody was ever asked, which then looks in the file exactly like something they were.

Two failures dominate. Collapsing driven by presentation rather than by the analysis plan quietly shapes results: a boundary moved, a category combined, a net composed, after somebody has seen a chart. And silent scale reversal produces output that is coherent, plausible and exactly inverted, with nothing wrong with the arithmetic to give it away.

This skill specifies every transformation before it is built, verifies scale direction item by item against the questionnaire, keeps every source variable, states the missing-component rule for every derivation, validates merge keys before merging, checks wave comparability before stacking, and verifies each derived variable against source on real cases rather than in aggregate. The codebook is a required output.

Best used for

  • Building the analysis file an analysis plan specifies
  • Verifying scale direction and catching a silently reversed item in a battery
  • Collapsing categories defensibly rather than for presentation
  • Constructing nets and indices with documented formulas
  • Banding continuous variables with honest treatment of boundary arbitrariness
  • Merging files without silent multiplication or unprofiled attrition
  • Stacking tracker waves only after a variable comparability check
  • Producing a codebook a dataset can be inherited from

Typical inputs

What you give it.

Cleaned dataset with cleaning log and missing-data conventions, Analysis plan or research objectives, Questionnaire as fielded, with every scale and its labels, Source codebook or data dictionary, Merge key definition and expected match rate, for any merge, Previous waves' questionnaires and codebooks, for any wave stack, Existing house or client conventions for bands, nets and indices (optional), Client record or panel profile data (optional), Intended reporting structure or table specification (optional)

Typical outputs

What you get back.

Analysis-ready dataset with every source variable retained, Transformation specification and log with re-executable rules, Scale register with direction verified against the questionnaire, Reversal log with formulas and cross-tab proofs, Collapse and band definitions with plan justifications and boundary sensitivity notes, Derived variable dictionary with formulas, missing rules and threshold justifications, Net definition table verified against direct counts, Merge report with key validation, match counts and matched-versus-unmatched profiles, Wave comparability table with break markers embedded in the data, Case-level verification record, Codebook covering every variable in the file

Method coverage

What the skill works through.

  1. What dataset preparation is, and where cleaning stops
  2. Specifying transformations before building them
  3. Verifying scale direction against the questionnaire, item by item
  4. Reverse-coding safely, and proving it worked
  5. Collapsing categories against the analysis plan, not the chart
  6. Deriving variables and documenting the formula
  7. Nets: why you never sum the parts
  8. Banding continuous variables and the arbitrariness it introduces
  9. Thresholds are findings, not descriptions
  10. Multi-response structures: dichotomies and mention sets
  11. Reshaping between wide and long
  12. Merging files and validating the key first
  13. Wave stacking and the comparability check that must come first
  14. Verifying every derived variable against source on real cases
  15. The codebook as a required output

Download

Free skill. One file.

Enter your email once. Every skill you download after that takes a single click.

How to install

Add the skill file and the five kernel protocols to a Claude Project, a ChatGPT Project, a Gemini Gem, or paste them at the top of any assistant conversation. Then give it your real research material, not a description of it.

Download skill

Questions

Common questions.

How do I know if a survey scale has been reverse-coded?

Check the questionnaire, item by item, and record for each scale which end is positive and what numeric code it carries. Do not read direction from the variable name or from the value labels in the data. Within a battery, the detection signal is an item that correlates negatively with the others: that usually means it was negatively worded and not corrected. A silently reversed scale is one of the most damaging undetected errors in research, because the output is coherent and plausible and simply means the opposite of what it says.

What is the correct way to reverse-code a variable?

Create a new variable rather than overwriting the original, use an explicit formula that includes the scale length (for a 1 to 5 scale, new equals 6 minus old), and prove it by cross-tabulating original against reversed and by confirming the item now correlates positively with the rest of its battery. Including the scale length in the formula is what stops a five-point rule being applied to a seven-point item, which is a common error in trackers where the scale changed.

When is it acceptable to collapse survey categories?

When the analysis plan says the finer distinction is not analysed, when a subgroup is too small to report separately, when the client's other data uses those groupings, or when a previous wave defined them that way. Never because a chart has too many bars or because a boundary puts a figure on the convenient side of a round number. Record the mapping and the reason, retain the source variable, and check the result: a collapse that puts 80% of the sample into one category has destroyed the variable regardless of the justification.

How do I build a net variable correctly?

Count the respondents who fall into any of the member categories, and verify that count directly. Never sum the individual percentages, because respondents who fall into more than one category are counted twice and the net is overstated, sometimes by a great deal. Define the net by its member codes, state its base, and be careful with the word itself: "net" also means the difference between two ends of a scale, and a file where both senses appear unlabelled will produce a wrong chart.

How should I choose band boundaries for a continuous variable?

There are three approaches and each has a cost. Substantively meaningful boundaries (a retirement age, a price point, a contract term) are the most defensible and rarely the tidiest. External standard boundaries buy comparability and may fit the data badly. Distribution-driven boundaries such as quartiles fit the data and do not travel: quartile boundaries move as the sample moves, so a top quartile in one wave is not the same group as a top quartile in the next. State the approach, keep the continuous variable, and test whether the conclusion survives moving a boundary that sits near a concentration of cases.

What should be in a codebook?

For every variable: name, label, type, valid values and their labels, missing codes and their meanings, whether it was collected or derived, the construction rule if derived, the base description, scale direction and length where applicable, wave availability, and any comparability break marker. The test is that somebody who has never seen the study can open the codebook and interpret any variable in the file without asking a question. Without one, a dataset stays interpretable for about as long as the person who built it remembers the details.

What can go wrong when merging two datasets?

Three things, all quiet. A key that is not unique in one file multiplies rows in a merge the analyst believes is one-to-one. A format mismatch (leading zeros, trailing spaces, case, text versus numeric keys) causes matches to fail invisibly. And the records that fail to match usually differ systematically from those that do, so an unprofiled merge attrition introduces a bias that looks like a finding. Validate key uniqueness in both files first, reconcile row counts after, and compare the profile of matched and unmatched records.

Can I combine tracker waves into one file?

Only after checking, variable by variable, whether question wording, response list and order, scale length and direction, routing and base definition, mode and missing conventions changed between waves. Classify each variable as comparable, comparable with a caveat, or not comparable. Put break markers into the data itself rather than only into a document, because once the waves are stacked a break is invisible and a movement caused by a wording change is indistinguishable from a real one.

How do I verify a derived variable is correct?

By hand, on real cases, not in aggregate. Take at least ten cases spanning the range, including one at each extreme, one with a missing component and one that crosses a band boundary, recompute the value from the source variables, and compare. Distribution checks pass while individual values are wrong: an off-by-one in a reversal, a band boundary applied exclusively where it should be inclusive, or a missing rule that silently produces a zero are all invisible in a histogram and obvious in one case.

What is the difference between wide and long data, and when do I reshape?

Wide means one row per respondent, and it is right for cross-sectional analysis and reporting. Long means one row per respondent per item, wave or occasion, and it is right for repeated measures, multilevel models and some visualisation tools. Reshape only when the analysis needs it, and check the arithmetic: rows in the long file should equal respondents multiplied by occasions minus any legitimately absent combinations. Any discrepancy means a duplicate key or a lost record.

Research where people already are.
Analyse it where you already work.

Yazi helps researchers conduct surveys, AI interviews and longitudinal research directly through WhatsApp.

New Report on SA Gambling Impact
Check It Out