Introduction
Many variables ask whether a particular condition is true: whether a patient experienced a symptom, whether a student submitted an assignment, or whether a device passed inspection. Each individual has one of two possible recorded categories. This simple structure is common in statistics, but it is easy to mistake a numerical code for a numerical measurement.
The key is to separate the outcome being recorded from the symbols used to store it. A response recorded as “Yes” or “No” is categorical. Recording those same categories as 1 and 0 may make data easier to organize, but by itself it does not turn the response into a quantitative measurement.
What Makes a Variable Binary?
For a variable to be genuinely binary, its categories must be clear and cover the possibilities relevant to the question. They also need to be distinct: one observation should not simultaneously belong to both categories. “Returned the form” versus “did not return the form by Friday” is more precise than an undefined “responded,” because the categories specify what is being classified and when.
The individual is still the unit being described. If a table has one row for each patient and records whether that patient reported a symptom, the individual outcome is the patient’s symptom status. It is not the number of patients with symptoms; that would summarize outcomes across multiple individuals.
0–1 Coding: Numbers Used as Category Labels
A common way to store a binary variable is to assign one category the code 1 and the other the code 0. For example, a data dictionary might define 1 as “Yes” and 0 as “No.” The mapping is a convention: the codes could instead be reversed, provided the meaning is stated and used consistently.
If the code is 1 for “Yes” and 0 for “No,” a code of 1 means the individual is in the “Yes” category. It does not, for example, mean that the individual has one unit of a substance. Likewise, 0 is not necessarily a measured absence or a meaningful physical zero; it may simply be the label chosen for the other category.
Because the codes are numbers, they can be added. That operation can be useful when the coding is known. If \(I_i=1\) when individual \(i\) is in the “Yes” category and \(I_i=0\) otherwise, then adding the codes gives the number of individuals in the “Yes” category:
This is a calculation on a collection of coded outcomes. It does not change what the original variable records for each individual: a category, not a measured quantity. Changing which category receives code 1 would change the sum, even though the individuals and their underlying outcomes remained the same.
Worked Example: Coding a Yes-or-No Response
In a hypothetical classroom exercise, six students are each asked whether they submitted a practice form by the stated deadline. The recorded responses are Yes, No, Yes, Yes, No, No. A data-entry guide specifies Yes = 1 and No = 0. Write the coded values and interpret them.
Applying the stated mapping in the same order gives:
The third entry is 1 because the third student answered Yes; the fourth entry is also 1 for the same reason. The entries 2, 5, and 6 are 0 because those students answered No. The coded data contain six individual binary outcomes.
Adding the codes gives \(1+0+1+1+0+0=3\). Under this specific mapping, the sum is the number of students coded Yes. It is not a measurement of “how much submission” occurred for any one student. The variable for each student remains the categorical response “submitted by the deadline” or “did not submit by the deadline.”
A Binary Outcome Is Not the Same as a Count
A binary outcome answers a two-category question about one individual. A quantitative count records how many occurrences or objects there are for an individual or other unit. Counts are numerical values for which differences and addition have a quantitative meaning; they can take values such as 0, 1, 2, and more, depending on what is being counted.
The wording of the variable makes the difference clear. “Did this patient experience at least one episode?” is binary: the possible answers are Yes and No. “How many episodes did this patient experience?” is a count: possible values include 0, 1, 2, and so on. The first records whether a condition holds; the second records its exact count.
| Variable recorded for one individual | Possible values | Type |
|---|---|---|
| Whether a package arrived by the promised date | Yes or No | Binary categorical |
| Number of days a package was delayed | 0, 1, 2, and so on | Quantitative count |
| Whether a machine produced any defective items in a shift | Yes or No | Binary categorical |
| Number of defective items produced in a shift | 0, 1, 2, and so on | Quantitative count |
Notice that both variables in a pair can describe the same unit and the same general situation, yet they are not interchangeable. A yes-or-no indicator can conceal how many occurrences took place. If the exact number matters, recording only Yes or No loses that detail.
Worked Example: One Outcome or an Exact Count?
In a hypothetical quality-control exercise, each of four machines is checked for whether it produced at least one defective item during a shift. The recorded answers are Yes, No, Yes, Yes. The quality team also records the exact number of defective items from each machine: 2, 0, 5, and 3. Classify both variables and explain the difference.
The first variable is “produced at least one defective item during the shift.” Its categories are Yes and No, so it is binary categorical. With Yes = 1 and No = 0, the recorded codes are \((1,0,1,1)\). Their sum is \(1+0+1+1=3\), meaning three machines were coded Yes.
The second variable is “number of defective items produced during the shift.” Its values are \(2,0,5,3\), which are quantitative counts. Their sum is \(2+0+5+3=10\) defective items across the four machines.
The two sums answer different questions: 3 is the number of machines with at least one defective item, while 10 is the total number of defective items. A machine with five defective items still contributes just one Yes to the binary outcome. The binary variable does not retain the exact count.
Checking a Coding Scheme
Before interpreting stored 0s and 1s, check the codebook or recording instructions. In particular, determine which category is assigned 1, which is assigned 0, and what the categories mean in context. If the mapping is not provided, the numbers alone are not enough to identify which observations represent “Yes.”
Reversing the coding is allowed if the new convention is explicit. Suppose \(I_i=1\) represents “Yes” and \(I_i=0\) represents “No.” Under the reversed scheme, define \(J_i=1\) for “No” and \(J_i=0\) for “Yes.” For every observation, the reversed code satisfies:
When the original six codes are \((1,0,1,1,0,0)\), the reversed codes are \((0,1,0,0,1,1)\). The category assigned to each student has not changed; only the numerical label has. Therefore, a numerical result based on the codes must be interpreted with the mapping in view.
Worked Example: Interpreting Reversed Codes
A hypothetical inspection file uses 1 for “passed” and 0 for “did not pass.” Five devices have codes \((1,1,0,1,0)\). A second file uses the opposite convention: 1 for “did not pass” and 0 for “passed.” Find the second file’s codes and explain why the underlying outcomes have not changed.
For each code \(I_i\) in the first file, the second file uses \(J_i=1-I_i\). Applying that rule gives \(1-1=0\), \(1-1=0\), \(1-0=1\), \(1-1=0\), and \(1-0=1\). Thus, the second file records \((0,0,1,0,1)\).
The original codes contain three 1s, so three devices passed under the first mapping. The second codes contain two 1s, so two devices did not pass under the reversed mapping. These statements describe the same five inspection outcomes. A statement such as “there are three 1s” is incomplete unless the code assigned to 1 is known.
A Short Justification for the Coding Sum
Why does adding the 0–1 codes count the individuals in the category assigned 1? Each individual contributes exactly 1 if that category applies and exactly 0 otherwise. Adding those contributions includes one unit for every member of the category and adds nothing for anyone outside it.
For example, if the responses are No, Yes, No, Yes and Yes is coded 1, the codes are \((0,1,0,1)\). The sum is \(0+1+0+1=2\). There are exactly two Yes responses. More generally, each term \(I_i\) contributes one precisely when individual \(i\) is in the coded category, so the sum counts those contributions. This reasoning relies on the stated 0–1 mapping; if the codes were 1 and 2, their sum would not directly equal the number of Yes responses.
Common Mistakes and Why This Distinction Matters
- “The values are numbers, so the variable is quantitative.” Not necessarily. When 0 and 1 are codes for two categories, they identify group membership; their appearance as digits does not establish a measured amount.
- “A 1 means one occurrence.” Only if the variable was defined as a count and 1 means one occurrence. In a binary code, 1 may mean “Yes,” “passed,” or another category, regardless of how many occurrences there were.
- “The number of Yes responses is the outcome for each person.” No. Each person has a binary outcome. The total number of Yes responses is a summary across people.
- “The category coded 1 is always the positive category.” There is no universal rule requiring this. Check the documented mapping; 1 might indicate either category.
These distinctions affect what conclusions a data set can support. A binary outcome can answer whether a condition occurred, but it cannot reveal its frequency within an individual when multiple occurrences are possible. A count can preserve that detail. Choosing and naming the variable accurately is therefore a substantive decision, not merely a formatting choice.
Check Your Understanding
Answer each question by identifying the variable being recorded and interpreting any numerical codes in context.
- A form records whether each applicant submitted a required document: Yes = 1 and No = 0. Is this a binary categorical variable or a quantitative count? Explain.
- A clinic records whether each patient had at least one follow-up visit and, separately, the exact number of follow-up visits. Which variable is binary, and which is a count?
- If a binary variable uses 1 for “No” and 0 for “Yes,” what does a recorded value of 1 mean? Why can’t you infer the meaning from the digit alone?
- Four observations are coded \((1,0,1,1)\), with 1 defined as “passed.” What does their sum represent? Show the arithmetic.
- Explain why recording only whether a machine produced any defective items does not tell you the exact number it produced.