I was playing around with an assessment that I need to calculate the socio-economic class.
I got it to work, but as this is my first major "programming" with EM, I was wondering if there might be a leaner, cleaner solution. I am using a lot of IF loops within the SUM function, maybe there is something better.
Code:
sum(CCEB1_1, CCEB1_2, if(CCEB1_3 == 1, 4, if(CCEB1_3 == 2, 5, if(CCEB1_3 == 3, 6, if(CCEB1_3 == 4, 7, 0)))), if(CCEB1_4 == 1, 4, if(CCEB1_4 == 2, 7, if(CCEB1_4 == 3, 9, if(CCEB1_4 == 4, 9, 0)))), if(CCEB1_5 == 1, 3, if(CCEB1_5 == 2, 4, if(CCEB1_5 == 3, 4, if(CCEB1_5 == 4, 4, 0)))), if(CCEB1_6 == 1, 2, if(CCEB1_6 == 2, 2, if(CCEB1_6 == 3, 2, if(CCEB1_6 == 4, 2, 0)))), if(CCEB1_7 == 1, 2, if(CCEB1_7 == 2, 2, if(CCEB1_7 == 3, 2, if(CCEB1_7 == 4, 2, 0)))), if(CCEB1_8 == 1, 4, if(CCEB1_8 == 2, 4, if(CCEB1_8 == 3, 4, if(CCEB1_8 == 4, 4, 0)))), if(CCEB1_9 == 1, 2, if(CCEB1_9 == 2, 2, if(CCEB1_9 == 3, 2, if(CCEB1_9 == 4, 2, 0)))), CCEB2)
So I have basically two questions.
The first one is an array question (CCEB1) with a scale from "0" to "4 or more" and has 9 subquestions. So I gave the scale items the values 0,1,2,3,4. For the first two sub-questions the points are equal to the response code. But for some sub-questions the actual points to gain do not follow the response code. I could have done this question in 9 separate questions and then give the respective answer codes, but for an array questions you can't give different answer codes per sub-question.
At the end there is a list radio question (CCEB2), where I could just apply the right points.
Is this already as clean as it gets? It works, but I was just wondering if there is a more elegant solution. If not, that is fine with me. Just trying to learn.