Announcement

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

  • average of each category of a categorical variable.

    I have two categorical variables - A (5 point scale strongly agree to strongly disagree) and variable B - similarly 5-point scale. I have data that has 5 subgroups (area of residence). I want to see the mean of respondents who have selected agree for variables A & B both for each subgroup.

    Can we do this in stata

  • #2
    Let's suppose agree is coded 4 on a 5 point scale. The answer is similar in principle for any other coding. Then you can

    Code:
    tabulate area if A == 4 & B == 4
    -- but I can't follow what "the mean of respondents" might be in this context. The mean on A and B if their values denote agree are just the codes for agree.

    If this isn't a good answer, I think you may need to explain more, or differently.

    Comment


    • #3
      Palana:
      as an aside to Nick's helpful reply, I guess that you are interested in those who ticked agree (say, 4) and strongly agree (say, 5).
      That said, you may want to consider something along the following lines:
      Code:
      . sysuse auto
      (1978 automobile data)
      
      . g faked_rep78=rep78
      
      
      . bysort foreign: sum rep78 faked_rep78 if rep78>=4 & faked_rep78>=4
      
      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      -> foreign = Domestic
      
          Variable |        Obs        Mean    Std. dev.       Min        Max
      -------------+---------------------------------------------------------
             rep78 |         11    4.181818    .4045199          4          5
       faked_rep78 |         11    4.181818    .4045199          4          5
      
      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      -> foreign = Foreign
      
          Variable |        Obs        Mean    Std. dev.       Min        Max
      -------------+---------------------------------------------------------
             rep78 |         18         4.5    .5144958          4          5
       faked_rep78 |         18         4.5    .5144958          4          5
      
      
      .
      Last edited by Carlo Lazzaro; 05 Jun 2023, 02:13.
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment

      Working...
      X