0% found this document useful (0 votes)
56 views

Excel Recoding

The document discusses recoding categorical and numerical variables in a spreadsheet. It provides examples of using the IF function to recode variables with one or more conditions. Specifically, it shows how to: 1) Recode a numerical grade variable into a categorical pass/fail variable using a single IF condition to check if the grade is above 50. 2) Assign letter grades using nested IF functions and AND conditions to check if the grade is within multiple ranges. 3) Recode grades into categories like "Merit" or "Pass without merit" using OR conditions to group letter grades.

Uploaded by

Daniel Parker
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Excel Recoding

The document discusses recoding categorical and numerical variables in a spreadsheet. It provides examples of using the IF function to recode variables with one or more conditions. Specifically, it shows how to: 1) Recode a numerical grade variable into a categorical pass/fail variable using a single IF condition to check if the grade is above 50. 2) Assign letter grades using nested IF functions and AND conditions to check if the grade is within multiple ranges. 3) Recode grades into categories like "Merit" or "Pass without merit" using OR conditions to group letter grades.

Uploaded by

Daniel Parker
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Recoding

The “if” command


RECODING
• Recoding Categorical Variables
• Select, copy, find-replace, enter value to replace, enter replace value and
replace all.

• Recoding Numerical variables into Categorical variable


• Use “IF” function with “AND” or “OR”

• IF function
IF with only one condition
• Grades file
• Find out if a student passed/failed based on percentage

=IF(T2>50, "Pass", "fail")


IF with “AND” conditions
• Assigning Grade “D”
• The conditionality will be the first to feature after the bracket

=IF(AND(T2>=50, T2<70), "D","")

=IF(AND(T2>=50, T2<70), "D",IF(AND(T2>=70,T2<80), "C", ""))

• Note that the closed brackets must equal the open brackets

Q1. Assign all grades, along with “fail” for those with marks below 50.
Solution

=IF(AND(T2>=50, T2<70), "D",IF(AND(T2>=70,T2<80), "C", IF(AND(T2>=80, T2<90), "B", IF(T2>=90, "A", IF(T2<50, "Fail")))))

Note the number of brackets

Q2. Convert the grades into numbers (1 to 5).


Q3. Use the “or” condition to get the following categories
Merit: If grade is A or B
Pass without merit: If grade is C or D
Fail: if grade is “Fail” or “F”, whichever you have selected
Solutions

Sol2.
=IF(AA2="A",1, IF(AA2 = "B",2, IF(AA2 = "C",3, IF(AA2 = "D",4, IF(AA2 = "Fail",5)))))

Sol3.
=IF(OR(AA2="A", AA2 = "B"), "Merit", IF(OR(AA2="C", AA2="D"),"pass without merit", AA2))

You might also like