UPI Study › Courses › Marketing Research › Free lessons › Lesson 9.1 Free lesson
Data Coding and Recoding in Excel
Marketing Research · Chapter 9: Statistical Measures and Data DistributionSection 9.1 · lesson 62 of 10110 min · free to watch
Lesson complete
Earn the 3 college credits for Marketing Research
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Statistical Software for Marketing Research →← How to Respecify and Transform Variables in ExcelNext lesson: Statistical Software for Marketing Research →
In this lesson
Coding survey answers with lookups and checking every code in Excel.
- Turn text answers into numeric codes with a lookup table
- Check codes with TRIM, COUNTIF and an error count
- Avoid the traps of find and replace when coding
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (1,504 words). Read along, or search it.
Opening Example
Typing 4 for 5,000 People
Imagine typing the number 4 next to every "agree," in a survey of 5,000 people. You would be at it for days. And you would certainly slip. Excel can do the whole job in one formula. And then it can tell you whether the job was done right. Coding by formula is faster. But the bigger win is that it can be checked. This is a hands-on lesson, so have a blank workbook open beside you.
In this lesson, you will turn text answers into numeric codes, with a lookup table. You will check the codes with TRIM, COUNTIF, and an error count. And you will avoid the traps of find and replace.
Lookup Coding
The Codebook Lives Next to the Data
First: a lookup table does the coding. Fernway Snacks is a composite case built for teaching. Grace has the answers to one Fernway statement: "Fernway bars are good value." She has them for ten shoppers, typed as words, in column B. The data is invented.
Her codebook, from lesson 8.6, says strongly disagree is 1, up to strongly agree, which is 5. In between, disagree is 2, neutral is 3, and agree is four.
Rather than typing codes by hand, she writes the codebook into the sheet. It becomes a small lookup table, in cells E1 to F6. Then she asks Excel to look each answer up. The table is the codebook, living right next to the data. And that matters. If the codebook ever changes, the table changes with it. One edit, and the whole column follows.
The formula in cell C2 uses XLOOKUP. In words, it says this. Find B2, in the answer list E2 to E6. And return the code beside it, in F2 to F6.
Error Signals
Hidden Spaces and a Typo
Its older twin is VLOOKUP. It also works, in versions of Excel without XLOOKUP. Fill either one down the column, and eight of the ten answers become codes at once. Ten rows or five thousand, the effort is the same. You write the formula once. Excel does the rest, without getting tired, and without slipping.
But two rows show errors. They read N, slash, A. That means no match found. Why? Excel matches whole cells. It ignores capital letters. But it does not ignore spaces.
In row eight, the answer is the word agree, with a hidden space at the end. That is a different string, from agree with no space. And in row nine, the answer is the word agree, missing its last letter. A typo. It is not in the table at all.
Loud Errors
The Formula Refuses to Guess
Here is the good news. The error is a loud signal. It sits right there in the column, impossible to miss. A code typed by hand would have hidden the problem. Someone tired would just type a four, and nobody would ever know the original was odd. The formula refuses to guess. And that refusal is exactly what you want.
Here is how it plays out at Fernway. Victor's fieldwork team sends a file, where some answers carry extra spaces from copy-and-paste. Grace's first lookup shows five errors. She wraps the answer in TRIM, and four of them vanish. The fifth is a real typo. She sends it back to Victor, instead of guessing. Notice the order of her work. First, the lookup flagged a problem. Then a simple fix cleared most of it. And what remained went to a person who could check the original. That is the right order every time.
TRIM and COUNTIF
Counting Your Change at the Counter
Next: checking the codes. Never trust a coded column, until you have checked it. Think of it like counting your change at a shop counter. It takes seconds, and it catches the mistakes that would cost you later.
The first repair is TRIM. It strips extra spaces from the start, and end, of text. Nest it inside the lookup, and the invisible space in row eight stops mattering. Row eight now gets its code: a four.
The typo in row nine stays an error, on purpose. A human should decide what that answer meant. Was it agree? Probably. But probably is not the same as checked. So it goes back to the field team.
The next tool is COUNTIF. It counts the cells in a range, that meet a condition. For example, COUNTIF counts fours in the code column.
Check Table
Counts That Add Up to Ten
Now build a small check table. Count each of the five codes. Then add a count of errors. All of those together should add up to the number of respondents. If they do not, someone is missing.
Here are Grace's numbers, after TRIM. One shopper gave a one. One gave a two. One gave a three. Four gave a four. Two gave a five. And there is one error. One, plus one, plus one, plus four, plus two, plus one, makes ten. So no respondent has vanished.
A condition can also be a comparison, in quotes. For example, COUNTIF can count the codes above five. That count should be zero, because five is the highest allowed code. Any number above zero means something slipped past. Maybe a stray six, or a missing-value code that was never declared. Either way, the check has done its job. It found a problem, while it was still cheap to fix.
Error Counts
SUMPRODUCT, ISNA and a First Finding
SUMPRODUCT works with ISNA to count the error cells. It counts how many cells show that N, slash, A. That number goes into the check table, so every row is accounted for. The check table is short. It takes a minute to build. And it turns a vague worry, did I miss anyone, into a single number you can see.
What does it mean? After TRIM, nine of ten answers are coded, and one needs a person. And notice that four of the ten agree. That is a first, tiny finding. Grace also checks the sheet in Python, as a second pair of eyes. It agrees with every cell.
And a pro tip. Keep the text answer column next to the code column, and never delete it. If a code ever looks odd, you can see the original word beside it.
And to flip a negative item, from lesson 8.6, add one more formula column. Six, minus the code. A code of five becomes one. And a two becomes four.
Find and Replace
Agree Hides Inside Other Labels
Finally: the find-and-replace trap. Find and replace looks tempting. Open the box, with control and the letter h. Type agree. Replace it with four. Click replace all. And you are done. Or so it seems. Here is what actually happens.
By default, Excel looks for the letters anywhere inside a cell. And it ignores capitals. The word agree is hiding inside four of the five labels. It sits inside strongly agree, disagree, and strongly disagree.
So look at the damage. Strongly disagree becomes strongly dis, four. Disagree becomes dis, four. Neutral is untouched, because it has no agree inside it. Agree becomes a four, which is right. Strongly agree becomes strongly plus the code for agree. Only agree became four. Three labels were damaged. And strongly agree was never coded as five.
Silent Failure
Protecting Yourself When Replacing
Even worse, no error appears. The sheet looks busy and finished. There is a four here, and a four there. Nothing turns red. Nothing warns you. So the damage can go unnoticed, until the numbers look odd. A lookup gives a loud error. Find and replace fails silently.
If you must use find and replace, protect yourself in three ways. Select the option that matches the whole cell contents. Select match case as well, when capitals matter. Replace in a copy of the column. And then check with COUNTIF.
Numbers as Text
Left-Aligned Numbers Get Skipped
Here is another common trap. A number that sits left-aligned in its cell is probably stored as text. And functions such as SUM, and AVERAGE, skip such cells. So a column can look full of numbers, and still give the wrong total. Numbers stored as text often come from pasted files, or from exports. Watch for them, especially when an average looks too small. A lookup table avoids all of this, because each answer is matched whole. Strongly agree is found as strongly agree, from its first letter to its last. Nothing inside it gets touched. That is why the lookup is the safer habit.
Key Takeaways
Always Code Into a New Column
And here is a common mistake. People overwrite the answers with their codes. Then they discover the codebook was wrong. Instead, code in a new column. If the codebook changes, say five should be one, you edit one cell in the table. And every code updates. The raw words are still there, untouched, so nothing is lost. That is the same rule you met in lesson 8.5: keep the raw data, and work in a copy.
Key takeaways. Code with a lookup table, and a formula, not by hand. Repair hidden spaces with TRIM. Verify with COUNTIF, and an error count, and keep the totals equal to the number of respondents. Avoid replace all on partial words. And always code into a new column. Next, in lesson 9.2, you will compare Excel with other statistical software. This lesson was made by UPI Study.
About Marketing Research at UPI Study
Marketing Research (Marketing 300) is a self-paced online course of 101 video lessons in 13 chapters, from consumer behavior, segmentation and the research process to qualitative methods, surveys and sampling, measurement, experiments, secondary and syndicated data, descriptive statistics, hypothesis tests, correlation and regression, research ethics and reports. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Business courses Every credit course with PRO →
Why take it here
Why students take Marketing Research with UPI Study
Where the credit goes
Universities that work with NCCRS
Marketing Research carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Data Coding and Recoding in Excel
How do you convert Likert text answers into numbers in Excel?
Why does a lookup return #N/A for an answer that looks correct?
How do you check coded survey data in Excel for errors?
Why is find and replace risky for coding survey answers?
About the Marketing Research course
How many college credits is Marketing Research?
How much does Marketing Research cost and what is included?
Which universities accept UPI Study credits?
How long does Marketing Research take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Marketing Research.
101 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
Updated
3 credits · NCCRSEnroll →