UPI Study › Courses › Marketing Research › Free lessons › Lesson 8.7 Free lesson
How to Respecify and Transform Variables in Excel
Marketing Research · Chapter 8: Secondary Data, Syndicated Sources, and Data PreparationSection 8.7 · lesson 61 of 10111 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: Data Coding and Recoding in Excel →← Encoding and Scoring Data in Marketing ResearchNext lesson: Data Coding and Recoding in Excel →
In this lesson
Regrouping, combining and transforming variables with Excel formulas.
- Group ages and combine categories with IF, IFS and a lookup table
- Create a new variable from existing ones, such as spend per bar
- Explain log and square-root transformations and when they help
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,521 words). Read along, or search it.
Opening Problem
Data in the Wrong Shape
The answers Fernway collected are rarely in the shape the analysis needs. Ages arrive as exact numbers, when Leo wants age groups. Five flavors need to become three families. And one shopper who spends 95 dollars drags an entire chart to the right. Excel can reshape all of it. And each fix is a formula, short enough to read aloud.
In this lesson, you will group ages, and combine categories, with IF, IFS, and a lookup table. You will create a new variable from existing ones, such as spend per bar. And you will explain log and square-root transformations, and when they help.
Respecify or Transform
Same Data, New Shape
First, respecifying keeps the same data but changes its shape. Respecifying a variable means changing how it is measured, or grouped, without collecting anything new.
Transforming usually means applying a mathematical rule to every value, such as taking a logarithm. Both start from an existing column. Both produce a new one. And both are done in a new column, so the original stays safe.
Fernway Snacks is a composite case built for teaching. Grace's workbook holds eight Fernway shoppers. The numbers are invented. There is a column for ID, one for age, one for monthly spend in dollars, one for favorite flavor, and one for bars bought per month.
Sheet Basics
Cell Addresses and a New Column
Picture a real sheet. It works like a grid of mailboxes. Column letters run across the top. Row numbers run down the side. And the formula bar sits at the top, showing what is inside the selected cell. Each cell has an address, like B2: column B, row two. Formulas point at those addresses. So one formula, filled down a column, can work on every shopper in turn.
Here is a common mistake. People type over the original age column with the group labels. Once the exact ages are gone, you can never regroup them, at thirty, or at forty. And you cannot check a doubtful label. So always make a new column.
Grouping With IF
Under 35 or 35 and Up
Next: grouping with IF, and IFS. Suppose Leo wants to compare shoppers under 35, with shoppers thirty five and over.
In cell F2, Grace types a formula that asks a question about cell B2. The IF function takes three parts. A test. The answer if the test is true. And the answer if it is false.
Here is how Grace's formula reads aloud. If B2 is thirty five or more, write the label thirty five and up. Otherwise, write under thirty five. Text answers go inside quotation marks. And the test uses a greater-than-or-equal sign, so the boundary age lands in the older group.
Take the first shopper, who is 22. Twenty two is not thirty five or more. So F2 shows under thirty five. Then Grace fills the formula down, for the other rows. The ages 36, 45, 52, and 41 give thirty five plus.
Grouping With IFS
Four Age Bands in One Formula
But two groups are rarely enough. What about four age bands? IF can be nested inside itself. But the formula gets hard to read, fast. Newer versions of Excel offer IFS. It lists test and answer pairs, one after another. And if your copy of Excel does not have it, nested IF does the same job.
Grace's IFS formula has four pairs. If the age is under twenty five, write eighteen to twenty four. If under thirty five, write twenty five to thirty four. If under fifty, write thirty five to forty nine. And the last pair is TRUE, then fifty plus.
Order matters, because IFS stops at the first test that is true. Take the shopper aged fifty two. That age fails the first three tests. Then it meets TRUE, which always passes. So it becomes fifty plus. The final TRUE works like the word else. Without a closing TRUE, a value that matches nothing gives an error.
Checking the Bands
Thin Bands and a Second Check
What does it mean? The eight shoppers split four and four, across the thirty five line. And they fall into bands of two, two, three, and one. A band with one person is too thin to analyze. So Leo may choose to merge it. And because grouping is now a formula, changing the cut-offs takes seconds.
Grace also checks the sheet in Python, as a second pair of eyes. The same rules, written as code, give the same labels, row by row. When two methods agree, you can trust the column. When they disagree, you have found a mistake, before Leo has seen a single chart.
Combining Categories
Five Flavors Into Three Families
Next: combining categories with a lookup. Fernway sells five flavors. But some have too few buyers to report separately. Nadia decides to combine them. Fewer, bigger groups are easier to read, and easier to trust.
Oat and nut go into one group, grain and nut. Berry and mango go into fruit. And cocoa stays on its own. That makes three families, instead of five flavors.
A long chain of IF tests would work. But a recoding table is cleaner. It is a small, two-column list of old value and new value, kept on the same sheet. After that, the lookup function finds each shopper's flavor in the table's first column. It returns the matching group.
Here is the formula in words. Look up B2, in the table E2 to F6. Return the value from its second column. And demand an exact match. That last part is the word FALSE.
Lookup Details
Dollar Signs Freeze the Table
Notice the dollar signs in the formula. They freeze the table's position. So when the formula is filled down to row nine, it still looks in the same place. Without them, the table would slide down the sheet, one row at a time, and the lookups would break.
Newer Excel versions also have XLOOKUP. It does the same job, without counting columns. You point it at the column to search, and the column to return.
Here is the scene at Fernway. Leo asks for sales by flavor. He gets a chart with five slivers, two of them tiny. Grace adds a recoding table, and a flavor group column, in ten minutes. The three-group chart is readable. And when the new fig bar launches, adding one row to the table is all it takes.
Updating the Table
Errors Flag Missing Flavors
What does it mean? If Nadia later moves the chocolate flavor into grain and nut, she edits one cell of the table. And every row updates. And if a new flavor appears that is not in the table, the formula shows an error: N, slash, A. That is useful. It tells you the table is incomplete, instead of guessing.
New Variables
Spend per Bar and Skewed Spending
Finally: new variables, and transformations. A new variable is created by combining existing ones. Dividing spend by bars gives spend per bar. That is a price-like number, that neither original column shows.
For example, one shopper spent ninety five dollars, on 20 bars. Divide, and round to two places. That gives 4.75 dollars a bar. The first shopper spent 18 dollars on six bars: 3.00 a bar.
For skewed numbers, there is another tool. Most shoppers in the sheet spend 12 to 30 dollars. But one spends 95. Charts and averages get dragged toward that single value.
A log transformation replaces each value with its natural logarithm. In Excel, it is written LN. It spreads small values apart, and squeezes large ones together. The square-root transformation, SQRT, does a gentler version of the same thing.
Log Transformation
Order Stays, Distances Shrink
Look at what happens. Before the log, the biggest spender is 7.9 times the smallest. After it, the ratio of the transformed values is only 1.8. The log of ninety five is 4.55. The log of twelve is 2.48.
And here is the key point. The ordering of shoppers never changes. Only the distances between them change. The biggest spender is still the biggest. But now, that one person no longer stretches the whole scale. Later techniques that work best on bell-shaped data often use such transformed values. You will meet them in lesson 9.6.
There is a cost, though. It is interpretation. A result in log dollars must be converted back, before it goes in a report for Leo. Leo thinks in dollars. So does every manager who will read the report.
Pro Tip
Logs Need Numbers Above Zero
And a pro tip. LN only works for numbers above zero. The log of zero gives an error, written as a hash, NUM, and an exclamation mark. A negative number does too. So if a column has zeros, decide on a rule first. Many analysts add 1 to every value, before taking the log. Then write that rule in the codebook, from lesson 8.6.
Try it yourself. In a blank sheet, type the ages 17, 24, 25, 34, thirty five, 50, and 51. Fill the IFS formula beside them. Which age lands on each boundary, and in which band? Predict first. Then check.
Key Takeaways
Reshape in New Columns
Key takeaways. Respecify and transform in new columns. Use IF, or IFS, to group numbers. Use a recoding table, with VLOOKUP or XLOOKUP, to combine categories. Use simple arithmetic to create a new variable. And use LN, or SQRT, to tame a long tail. Check each formula on a few rows by hand. Next, in lesson 9.1, you will code and recode survey answers in Excel. 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 How to Respecify and Transform Variables in Excel
How do you group ages into bands in Excel?
How do you combine categories with a recoding table in Excel?
When should you use a log transformation on marketing data?
What is the difference between respecifying and transforming a variable?
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 →