Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generate sum of variables from a questionnaire

    Dear All,

    I'm trying to generate a sum of variables generated from a questionnaire.
    Unfortunately to be able to score this questionnaire some answers are not coded in whole numbers.

    I'll try to explain:
    1. Question: How are you?
    Answer choices: bad "=" 1, good "=" 2.5, great "=" 5

    2. Question How do you feel compared to last month?
    Answer choices: worse "=" 1, slightly worse "=" 2.4, same "=" 3.6, slightly better "=" 4.8, way better "=" 5

    To score this questionnaire the numerical value of the answers should be added up together.
    Now, summing up these variables is easy when the values are whole number since you can change the value label to whatever number you need and sum it up this way.
    Unfortunately STATA does not let me change the value labels to numbers like 2.5 since only integers are allowed.

    Is there any other way that I can tell STATA that "good = 2.5"?

    Thank you very much for you help!

  • #2
    Sorry, but I don't understand the question. Adding variables that are numeric but not necessarily integer is easy enough. The result will typically not be an integer and so can't be matched by a value label but in what sense is that a problem?

    Comment


    • #3
      Thanks a lot for your quick reply.
      I'll try to rephrase my question.

      I did a survey and imported the results into Stata.
      Every question is imported as a variable and every answer is imported a as value (with the corresponding label 1,2,3 etc.)
      My task is to score this questionnaire. Every answer is scored with a number and summed up with the number of the other answers to give me the result. (For example answer to question 1 (= 5) + answer to question 2 (= 2.5) --> 7.5 would be the end result)
      When the answer is scored with a whole number (e.g. bad = 1, I can assign the value label 1 to this answer and use it for my calculation)
      Unfortunately, some answers require me to use numbers such as 3.3 or 4.4, therefore I can't use the value labels to calculate my score because value labels need to be whole numbers.

      My question is, if there is another way to assign the number I want to the answer (displayed as a value in Stata).




      Comment


      • #4
        If you add numeric variables, you add their numeric values. Whether there are value labels -- or what the value labels are if there are any -- are both irrelevant.

        I don't know if that answers your question, nor I yet understand why addition appears problematic.

        Perhaps you could usefully follow https://www.statalist.org/forums/help#stata and use dataex to give a data example to explain your puzzlement.

        Comment


        • #5
          I believe what is described in post #1 is that there is a variable read as a string that can take the values "bad", "good", or "great". To create a numeric variable taking the values 1, 2, and 3 respectively, we know how to use encode with a value label to accomplish that. But to create a numeric variable taking the values 1, 2.5, and 5 we cannot create a value label for the value 2.5.

          I have a workaround - multiply everything by 10, so that you're looking at 10, 25, and 50 as value lables - but I think it has too high a risk of leading to programming errors and would not advise it.

          Comment


          • #6
            Originally posted by William Lisowski View Post
            I believe what is described in post #1 is that there is a variable read as a string that can take the values "bad", "good", or "great". To create a numeric variable taking the values 1, 2, and 3 respectively, we know how to use encode with a value label to accomplish that. But to create a numeric variable taking the values 1, 2.5, and 5 we cannot create a value label for the value 2.5.

            I have a workaround - multiply everything by 10, so that you're looking at 10, 25, and 50 as value lables - but I think it has too high a risk of leading to programming errors and would not advise it.
            Yes that is exactly my problem.
            Thank you for you suggestion, maybe I can make it work that way.

            Have a nice day!

            Comment


            • #7
              On reflection, I disavow the suggestion I made above.

              I think the appropriate way of handling this problem is to create two variables. The first is a simple coding into values 1, 2, 3 that can have value labels and are suitable for tabulation and for use as indicator variables in modeling. (You may think you don't need this for what you are doing, but you may well need this once what you are doing now is reviewed by others.) The second is the "score" corresponding to that value - 1, 2.5, or 5. Here's an example.
              Code:
              . input str8 howareyou
              
                   howareyou
                1. bad
                2. good
                3. great
                4. ""
                5. end
              
              . label define howval 1 "bad" 2 "good" 3 "great"
              
              . encode howareyou, generate(how_val) label(howval)
              
              . recode how_val (1=1) (2=2.5) (3=5), generate(how_score)
              (2 differences between how_val and how_score)
              
              . label variable how_val "How are you doing?"
              
              . label variable how_score "How are you doing? score"
              
              . tab how_val how_score, missing
              
                 How are |          How are you doing? score
              you doing? |         1        2.5          5          . |     Total
              -----------+--------------------------------------------+----------
                     bad |         1          0          0          0 |         1 
                    good |         0          1          0          0 |         1 
                   great |         0          0          1          0 |         1 
                       . |         0          0          0          1 |         1 
              -----------+--------------------------------------------+----------
                   Total |         1          1          1          1 |         4

              Comment


              • #8
                Originally posted by William Lisowski View Post
                On reflection, I disavow the suggestion I made above.

                I think the appropriate way of handling this problem is to create two variables. The first is a simple coding into values 1, 2, 3 that can have value labels and are suitable for tabulation and for use as indicator variables in modeling. (You may think you don't need this for what you are doing, but you may well need this once what you are doing now is reviewed by others.) The second is the "score" corresponding to that value - 1, 2.5, or 5. Here's an example.
                Thank you, this helped me immensely!

                Comment

                Working...
                X