Dear all,
I have a variable that identifies the household (hid), a variable that
identifies the number that each individual has within the household
(pid) and finally a variable that has some values of interest (present
only for some individuals).
I would like to create a new variable (var2) that has the value of var1
for all the pid in the same hid (as in the example below).
hid pid var1 var2
1 1 10 10
1 2 10
2 1 6
2 2 6 6
2 3 6 6
2 4 6
3 4 8 8
3 5 8
One way to do it is:
by hid: egen var2=mean(var1)
However, I was wondering if there was any command that rather than
taking averages, could copy that value to everybody with the same hid.
Thank you
Manos
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/