Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: how to create average income of same cohorts?


From   Mirko <[email protected]>
To   [email protected]
Subject   st: how to create average income of same cohorts?
Date   Tue, 15 May 2007 20:56:07 +0100

Dear Statalister

I am trying to re-write a question  I posted yesterday, in case it was
not clear. I also change my title hoping this is a better one.

I have prepared the following example.
Given this data:

id   region  educ  age     income
1	2	1	25	5
1	2	1	26	5
2	2	1	29	8
2	2	1	30	8
3	2	1	32	11
3	2	1	33	11
4	1	1	40	5
4	1	1	41	5
5	1	2	37	8
5	1	2	38	8
6	1	2	42	9
6	1	2	43	9

I need to create the variable yref, that is the average income of a
reference group defined by the same level of education, the same
region and the same cohort (i.e., people who are 5 years younger and 5
years older).

Below I show the database with the new variable yref, that I've created manually

id region  educ   age      y       yref
1       2       1       25      5       6.5
1       2       1       25      5       6.5
2       2       1       29      8       8
2       2       1       29      8       8
3       2       1       32      11      9.5
3       2       1       32      11      9.5
4       1       1       40      5       5
4       1       1       40      5       5
5       1       2       37      8       8.5
5       1       2       37      8       8.5
6       1       2       42      9       8.5
6       1       2       42      9       8.5

For id=1 yref is the average of the income of id 1 and
2 (but not 3). id=3 does not belong to the same cohort as id 1 and 2.
For id=2 the mean is the average of the income of persons 1 , 2 and 3.
For id=3 the mean is the average of the income of persons 2 and 3 (but
not 1).

The problem for me is how to tell Stata to pick only the incomes of
people that are in the same cohort while computing the average
incomes.

Hope this is clear and that somebody can help me!

Thanks a lot,

Mirko
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index