Data Coding and Recoding in Excel, Explained

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

← How to Respecify and Transform Variables in ExcelNext lesson: Statistical Software for Marketing Research →

Earn 3 college credits for Marketing ResearchRecommended for credit by NCCRS · Marketing 300 · self-paced · one payment, lifetime access

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.

Compare: Principles of Marketing vs Marketing Research

Why take it here

Why students take Marketing Research with UPI Study

Turn customer questions into evidenceMarketing Research teaches how companies find out what customers want: defining the problem, interviews and focus groups, survey design and sampling, measurement scales, experiments, secondary and syndicated data, and data analysis from descriptive statistics to hypothesis tests, cross-tabs and regression, ending with the research report. It suits marketing and business degrees.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

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.

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?
Write the codebook into the sheet as a lookup table, then look up each answer. For example, =XLOOKUP(B2,E2:E6,F2:F6) finds the text in the answer list and returns its code, such as 4 for agree; VLOOKUP does the same job in versions without XLOOKUP. Fill the formula down a new column and keep the original text beside it.
Why does a lookup return #N/A for an answer that looks correct?
#N/A means no match was found. Excel lookups ignore capital letters but not spaces, so agree with a hidden trailing space does not match agree. Wrapping the lookup value in TRIM, as in XLOOKUP(TRIM(B2), and so on, removes the extra spaces and fixes those rows. A real typo, such as a missing letter, stays an error and should go back to someone who can check the original.
How do you check coded survey data in Excel for errors?
Build a small check table. Use COUNTIF to count each code, for example COUNTIF(C2:C11,4), and count error cells with SUMPRODUCT and ISNA. All the counts together should equal the number of respondents. Also count values above the highest allowed code with COUNTIF(C2:C11,">5"); any result above zero means a stray value or an undeclared missing code slipped through.
Why is find and replace risky for coding survey answers?
By default, Excel's find and replace matches text anywhere inside a cell and ignores capitals, so replacing agree with 4 also damages disagree, strongly disagree and strongly agree. No error appears, so the damage is silent. If you must use it, tick match entire cell contents, use match case when capitals matter, work in a copy of the column, and check the result with COUNTIF.

About the Marketing Research course

How many college credits is Marketing Research?
Marketing Research (Marketing 300) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Marketing Research cost and what is included?
$250, paid once, with lifetime access: all 101 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Marketing Research take?
It is self-paced with no deadlines. The 101 lessons total about 19 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

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

Marketing Research
3 credits · NCCRS
Enroll →