Announcement

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

  • How to create a composite score of variable values?

    I have 30 variables (ehp_1 through ehp_30) that correspond to survey questions - each variable is coded 0-4 on a Likert scale with 0 being "Never" and 4 being "Always." The variable is in byte format in Stata. I am attempting to create a composite score of the variable values. I attempted:

    gen pain_score = ehp_1 + ehp_2 + ehp_3 + ehp_4 + ehp_5 + ehp_6 + ehp_7 + ehp_8 + ehp_9 + ehp_10 + ehp_11
    gen control_score = ehp_12 + ehp_13 + ehp_14 + ehp_15 + ehp_16 + ehp_17

    However, after testing the formula manually, the numbers generated above for pain_score and control_score ^ are not corrected. Any idea what to do here?

    Thanks!

  • #2
    Your post is not very informative. You need to show us the exact Stata output and explain why it is different from your expectation. See also the -rowtotal()- function of egen

    Code:
    help egen

    Comment


    • #3
      Well, I have never known Stata to get its arithmetic wrong in this kind of situation. So I'm wondering what you mean when you say the results "are not corrected." For advice, I think we will need to see some example data that exhibits the problem, along with an explanation of how what the code produces differs from what you want.

      Please post back and use the -dataex- command to show example data. (You only need to show the relevant variables ehp_1 through ehp_17.) If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

      Added: Crossed with #2

      Comment


      • #4
        My guess is that Mollie asked for a sum but really wants a mean.

        If none of these guesses are right, we need more information please.

        Comment


        • #5
          Thank you! I ran dataex and ended up figuring out my mistake. I'll make sure my next post is more informative.

          Comment

          Working...
          X