Announcement

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

  • microdata cleaning

    dear members
    I have a data of household survey. the households are divided into PSU's (primary sampling units). these PSU's are defined on the basis of location i.e. if they collected data from 5 different areas in a city, these 5 areas are defined by 5 PSUs, placing all the households in an area in a single PSU. Number of households vary in each PSU. Other information given is on the income and consumption of each household
    I want to calculate median income for each PSU and then add a variable in my dataset, calculated by using formula, (Income of the household) / (Median income in PSU).
    please help me how I can do it in stata

    Thank you
    Last edited by Nadeem Sarwar; 03 Dec 2016, 01:54.

  • #2
    Code:
    help egen

    Comment


    • #3
      Dear Nick Cox
      thanks for replying, i read all that but could not get the solution. may be because i am new to data analysis and stata
      can u please help a little more with bit more explanation?
      thank you

      Comment


      • #4
        The egen command has a median option. "By" is an option you can use with many Stata commands to group observations. You'll use something like

        Code:
        egen med_inc = median(income), by(PSU)

        Comment


        • #5
          thank you so much Branden Galley

          it worked exctly as i wanted. thank you

          Comment

          Working...
          X