Announcement

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

  • Calculate categorical mean

    Hi,

    I have a number of variables (questions from a questionnaire) which are all categorical variables coded 1 - 4. I want to calculate the categorical mean for each question and do this by sex. Is there a way to do so?

    Thanks in advance


  • #2
    Well if these variables are truly categorical, like red, blue, green, and yellow in some arbitrary 1, 2, 3, 4 coding, it makes no sense at all to calculate a mean.

    I'll assume you mean that the variables are discrete variables 1-4 but where the numbers 1, 2, 3, and 4 really represent a quantity of something, or can be reasonably treated as if they do. In that case:
    Code:
    collapse (mean) q1 q2 q3 q4, by(sex)

    Comment


    • #3
      Thanks Clyde and yes you assume correctly, the 1 - 4 represents the percentage of individuals who answered the questions in a certain way. Where in the code do I specify the specific variable of interest (the question) and I will need to repeat this for each question I have (37 questions).

      Comment


      • #4
        What do you mean by "the specific variable of interest?" You said you had four questions. I think the code in #2 is pretty clear, and requires only that you replace q1, q2, q3, and q4 by the names of the four question variables, and sex by the name of the sex variable in your data. If you are not familiar with the -colllapse- command, run -help collapse- to learn more.

        Comment

        Working...
        X