Announcement

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

  • How to generate a variable in this case?

    Dear all,

    I need to create a variable V described as follows: "V is measured using the share of people participating in non-farm activities in relation to the total working population in the village, or the share of non-farm working hours to total working hours, again at the village level". Since I don't have information on working hours, I provide example data on types of work and village below. Any help is much appreciated. Thank you.
    Code:
    clear
    input float(village work)
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    1 0
    2 0
    2 0
    2 0
    2 0
    2 0
    2 0
    2 0
    2 0
    2 1
    2 0
    2 0
    2 0
    2 1
    2 0
    3 1
    3 0
    3 0
    3 1
    3 0
    3 0
    3 0
    3 0
    3 0
    3 0
    3 0
    3 0
    3 0
    3 0
    3 0
    3 1
    3 0
    3 0
    3 0
    4 0
    4 0
    4 0
    4 1
    4 0
    4 0
    4 1
    4 0
    4 0
    4 0
    5 0
    5 0
    5 0
    5 0
    5 0
    5 0
    5 0
    5 0
    5 0
    5 0
    5 0
    5 0
    5 1
    5 0
    5 0
    5 1
    5 0
    5 1
    5 0
    5 0
    5 0
    5 1
    6 0
    6 0
    6 1
    6 0
    6 0
    6 0
    6 0
    6 1
    6 0
    6 0
    6 1
    6 0
    6 0
    6 0
    6 1
    6 0
    6 1
    6 0
    6 0
    6 1
    end
    label values work work
    label def work 0 "Farming", modify
    label def work 1 "Non-farm", modify

  • #2
    Code:
    by village, sort: egen wanted = mean(work)
    This works because you have, happily, coded work as 0 for farming and 1 for non-farm. So the proportion of non-farms is just the average value of the work variable.

    Comment


    • #3
      Thank you, Prof. Clyde for the kind help as always .

      Comment

      Working...
      X