Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: TIME AVERAGE OF A DUMMY VARIABLE


From   [email protected]
To   <[email protected]>
Subject   st: TIME AVERAGE OF A DUMMY VARIABLE
Date   Thu, 8 Dec 2005 17:11:37 -0000

Dear Statalisters,
I have a data set which is sorted by nr (person identification number) and
year(1980-1987).
I want to create a variable for the time average of a "married" which is a
time-varying dummy variable(taking a value of either zero or one). 
I have tried for instance:
sort nr, year
tsset nr, year
gen x=.
by nr year: replace
x=(married*d80+married*d81+married*d82+married*d83+married*d84+married*d85+m
arried*d86+married*d87)/8
 
The point is that I want to have the resulting average value NOT to be time
variant for each individual e.g: if say marital status is taking a value of
one for 4 years and zero for the remaining 4 years for a given individual I
want the resulting variable to take a value of 1/2 for each year for the
given individual.
I have tried many alternative specifications and although this seems fairly
easy in practice it turns out to be rather tricky.
Would be most grateful if someone could help!
Georgios


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