Announcement

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

  • How to combine multiple observations for a single variable

    Hi I'm hoping someone can help me with combining new variables

    I'd like to combine six observations into one new variable. There are six organizations in my dataset and four observations for each, the first observation being they actively participate in an organization. I'd like to see a cross tabulation between political interest and the population that actively participates in these organizations.

    For the new variable i've done:

    gen active_members = .
    replace active_members = 0 if ReligiousOrg == 1 | ProfessionalOrg == 1 | Union == 1 | Charity == 1 | Army == 1 | NeighborhoodOrg = 1

    When I tabulated Political Interest with active_members the data it gave me was wrong.

    I basically want to find the total number of people that answered belong/participate and avoid double counting people who participate in multiple organizations.

  • #2
    Your problem is that you are creating a 0 (yes)/ (no). variable when what you need you need a variable coded 0 (for no) and 1 (for yes). (-tabulate- ignores observations with missing values by default.)

    So first, verify that the variables ReligiousOrg ProfessionalOrg Union Charity Army and NeighborhoodOrg are all coded 0 for no and 1 to yes. If they aren't, recode them that way. (-replace- or -recode- will do this).

    Once you are sure those variables are correctly 0/1 coded it's just:

    Code:
    egen active_members = rowmax(ReligiousOrg ProfessionalOrg Union Charity Army NeighborhoodOrg)

    Comment

    Working...
    X