Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <n.j.cox@durham.ac.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: creating variable summarizing for each individual properties of other members of a group at t-1 |

Date |
Tue, 17 May 2011 17:47:53 +0100 |

I don't know what "I am familiar with" means here. Does it mean that you've read the FAQ but can't see how to apply it? This sounds to me like 1. Get the sum of all individual entries sort yearmonth gen score = sum(ind_entry) by yearmonth : replace score = score[_N] 2. Subtract this individual replace score = score - ind_entry 3. Look one step back in time bysort ind_id (yearmonth) : gen prevscore = score[_n-1] Nick n.j.cox@durham.ac.uk Erik Aadland I need to create a variable that sums for each individual in my dataset the total number of ind_entry of all other individuals at time: yearmonth - 1. I have attached a small ex of my data structure below. So for instance, given the small dataset below, for ind_id 2 in yearmonth 11 this variable score = 1. But for ind_id 4 in the same yearmonth, the score = 0. I would also like to generate a variable that identifies for each individual the unique number of other individuals in the dataset that have experienced ind_entry = 1 at least once up until time: yearmonth - 1. I am familiar with the following FAQ: http://www.stata.com/support/faqs/data/members.html My data structure is snapshot data in principle like the example below, but some individuals enter the observation window later than others (i.e. in later yearmonths): year month yearmonth ind_id ind_entry 2003 10 10 2 0 2003 11 11 2 0 2003 12 12 2 0 2004 1 13 2 0 2004 2 14 2 1 2004 3 15 2 0 2003 10 10 4 1 2003 11 11 4 0 2003 12 12 4 1 2004 1 13 4 0 2004 2 14 4 0 2004 3 15 4 0 * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: RE: creating variable summarizing for each individual properties of other members of a group at t-1***From:*Erik Aadland <erikaadland@hotmail.com>

**References**:**st: creating variable summarizing for each individual properties of other members of a group at t-1***From:*Erik Aadland <erikaadland@hotmail.com>

- Prev by Date:
**st: dhs data in stata number of obs and population size** - Next by Date:
**Re: st: XTLOGIT: Predicted Diminishing Returns** - Previous by thread:
**st: creating variable summarizing for each individual properties of other members of a group at t-1** - Next by thread:
**RE: st: RE: creating variable summarizing for each individual properties of other members of a group at t-1** - Index(es):