Announcement

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

  • count

    Hello, I've been looking for the command to create the variable in yellow, using "bysort folio2 ls04: gen mujeres=_N" I created "count" but I don't know how to create variable "mujeres por hogar", can you help me please?
    Click image for larger version

Name:	question stata.jpg
Views:	2
Size:	27.7 KB
ID:	1345772

  • #2
    Code:
    egen mujeresporhogar = total(sexo == 3), by(hogar)

    Comment


    • #3
      thank you very much Nick!!

      Comment


      • #4
        Originally posted by Nick Cox View Post
        Code:
        egen mujeresporhogar = total(sexo == 3), by(hogar)
        Sorry Nick Cox,

        If I have more than 1 condition as in her example (sexo == 3 and z==0 for example), how can I modify the command.
        I try with the following, but it doesn't work:
        Code:
         
         egen mujeresporhogar = total(sexo == 3 & z==0), by(hogar)
        Thank you for your consideration

        Comment

        Working...
        X