Why Create a Derived Variable?
A data set can include variables recorded directly, such as a person’s date of birth, height, or daily spending. It can also include variables created from those records. For example, date of birth can be used to assign an age group, height and weight can be used to calculate body-mass index, and daily spending values can be added to obtain a weekly total. These are derived variables: their values are obtained by applying a stated rule to one or more existing variables.
A derived variable can make a data set easier to use or describe. But its values are only as clear and consistent as the rule that creates them. A category such as “young adult” needs defined boundaries; a total needs a defined time period and set of included values; a calculation needs specified units. Without those details, two people may create different values from the same source records.
From Source Values to New Values
A derived variable keeps the same individuals as its source data: it adds a new description for each individual rather than creating new individuals. For each row, the rule takes the existing value or values and produces one new value, when the required inputs are available. A complete definition should let someone else reproduce that value from the same inputs.
The new variable can be categorical or quantitative. Assigning each participant to an age band creates a categorical variable. Calculating body-mass index creates a quantitative variable. Adding seven daily amounts creates a quantitative weekly total. The fact that a value is derived does not determine its type; the meaning of the resulting values does.
Identify the recorded variable or variables used, including units and, when relevant, the date or time period to which they refer.
Give the exact calculation or category boundaries. Specify how boundary values are treated.
Say what happens if an input is missing, invalid, or outside the rule’s stated range.
Describe what one resulting value means and include units for quantitative values.
Creating Age Groups
Age can be recorded quantitatively, for example as completed years on a specified date. Age groups transform that detailed value into categories. This can make a summary more accessible, but it also removes distinctions between people who fall in the same group. The boundaries must be explicit so every eligible age fits one group and no age fits two.
For instance, the bands “18–29,” “30–44,” and “45–64” use integer ages and include both endpoints in each stated range. If age is stored in completed years, a person aged 29 belongs to the first band and a person aged 30 to the second. The rule should also say what to do with ages below 18, ages 65 or older, and missing ages, rather than silently leaving their status ambiguous.
Worked Example: Assigning Participants to Age Groups
Suppose a hypothetical survey records each participant’s age in completed years on 1 October 2026. Create a categorical variable with the groups 18–29, 30–44, and 45–64. For this example, values below 18 or above 64 are coded “outside defined range,” while a missing age remains missing.
The source is age in completed years on the stated date. The category rule is: assign “18–29” for ages from 18 through 29, “30–44” for ages from 30 through 44, and “45–64” for ages from 45 through 64. The categories do not overlap, and together they cover every integer age from 18 through 64.
For a participant aged 29, the value is “18–29,” because 18 ≤ 29 ≤ 29. For a participant aged 30, the value is “30–44,” because 30 ≤ 30 ≤ 44. For a participant aged 52, the value is “45–64,” because 45 ≤ 52 ≤ 64. An age of 17 is “outside defined range,” not “18–29”; a missing age produces a missing derived value.
The resulting variable is categorical: its values are group labels, not quantities to add or average. This rule is reproducible because it specifies the reference date, age unit, category boundaries, and handling of out-of-range and missing values.
If ages are calculated from dates of birth rather than already recorded in completed years, the reference date and age-calculation rule matter. A person’s age changes over time; using the same birthday data with different reference dates may give different age groups. A derived variable should therefore refer to a clearly specified time, not simply say “age group.”
Calculating Body-Mass Index
Body-mass index (BMI) is a quantitative variable calculated from weight and height. With weight measured in kilograms and height in metres, its numerical value is weight divided by squared height. Height must be converted to metres before applying this version of the formula; entering centimetres directly changes the result by a factor of 10,000.
Worked Example: Calculating BMI From Weight and Height
Imagine a hypothetical participant with a recorded weight of 68.0 kg and a height of 1.70 m. Calculate BMI, showing the units and arithmetic.
Both measurements are already in the units required by the formula. Substitute the values:
The derived quantitative value is approximately 23.53 kg/m². It is a calculation from the recorded weight and height, not a new measurement directly observed in the participant. This example illustrates how to construct the variable; interpreting BMI for a particular purpose requires additional context and is not part of the calculation rule.
For comparison, 1.70 m is 170 cm. If the weight is 68.0 kg but the height is mistakenly entered as 170 in the metre-based formula, the result is \(68.0/(170^2)\), which is not the participant’s BMI in kg/m². Consistent units are part of the variable’s definition, not a cosmetic detail.
Forming a Weekly Total
A total is a derived quantitative variable produced by adding defined component values. To create a weekly total, specify which days count as the week, what quantity is being added, and the units. If the total is intended to represent seven days, it is also important to decide what to do when one or more daily values are missing. Treating missing as zero is not automatically justified: “not recorded” does not necessarily mean “none.”
Worked Example: Adding Daily Values to Create a Weekly Total
Suppose a hypothetical diary records one person’s exercise time for each day from Monday through Sunday, in minutes: 20, 0, 35, 25, 40, 30, and 10. Define weekly exercise time as the sum of these seven daily values.
The rule uses all seven days of the specified Monday–Sunday week, and the input and output units are minutes. Applying the rule:
The derived weekly total is 160 minutes of recorded exercise. The zero on Tuesday is an observed value meaning no exercise was recorded for that day; it is not a missing value. If, instead, Tuesday’s entry were missing, the seven-day total would not be fully known from these records. A clear data rule might leave the weekly total missing unless all seven daily values are present, or might calculate a partial total and label it as such. Those are different variables and should not be confused.
The same approach works for other quantities, such as daily spending or number of pages read, provided the values refer to compatible units and the chosen week is defined. Adding values that cover different time periods, use different units, or count overlapping events may produce a number that is arithmetically correct but does not mean what the variable name suggests.
What a Transformation Preserves
Some derived variables retain all the information in their inputs; others deliberately simplify it. A weekly total compresses seven daily values into one number. Many different daily patterns can give the same total: for example, 10 and 20 minutes on two days has the same two-day total as 15 and 15 minutes. The total records the sum but not how it was distributed across days. Similarly, age-group assignment retains the band but loses the exact age within that band.
The distinction follows directly from how the rules map input values to outputs. If distinct input records can produce the same derived value, the derived value alone cannot identify which input record occurred. For age grouping, ages 20 and 28 both map to “18–29,” even though 20 ≠ 28. Therefore the group label does not preserve the exact age.
By contrast, a derived variable need not lose information in every case. If height is fixed and known, the BMI formula is one-to-one in weight: for a fixed positive \(h\), multiplying both sides by \(h^2\) gives \(w=\mathrm{BMI}\times h^2\). But BMI alone does not generally identify both weight and height, because different pairs can give the same ratio. Whether a transformation is useful depends on the question and on which details need to remain available.
Common Mistakes
- Leaving category boundaries vague. “Young, middle-aged, and older” does not specify where each category starts or ends. Give explicit ranges and say how boundary values are assigned.
- Using incompatible units. BMI calculated with height in centimetres in a formula requiring metres is incorrect. Convert the input before applying the formula.
- Confusing zero with missing. A recorded zero exercise time is a value; an unrecorded day is unknown. Do not replace missing values with zero without a justified and stated rule.
- Naming a total without defining its period. “Weekly total” needs a specified week and included days. The total can change if the period changes.
- Assuming a derived variable is a direct observation. BMI and weekly totals are computed from other values. Their meaning depends on the source measurements and the construction rule.
- Assuming a category keeps all the original detail. An age band does not reveal someone’s exact age. Preserve the source variable when that detail may be needed.
Check Your Understanding
Try these questions by stating the rule as well as the resulting type of variable.
- A data set records ages in completed years. Define non-overlapping categories for ages 0–17, 18–64, and 65 or older. What category receives age 64, and why?
- A participant weighs 72.0 kg and is 1.80 m tall. Write the BMI calculation and give the result in kg/m².
- A daily record contains values of 12, 0, 18, 20, 15, 10, and 5 minutes from Monday through Sunday. What is the weekly total, and what does the zero mean if it was recorded?
- Explain why replacing an unrecorded daily value with zero can change the meaning of a weekly total.
- Two people aged 22 and 27 both receive the category “18–29.” What information about age is lost in this derived variable?