Nick
[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Alex Ogan
> Sent: 06 April 2006 21:39
> To: [email protected]
> Subject: RE: st: RE: How to construct a duration variable?
>
>
> Here's one in two lines:
>
> bysort hhid (period): gen tempvar = sum(switch)
> bysort hhid tempvar: gen myduration = _N
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Nick Winter
> Sent: Thursday, April 06, 2006 4:14 PM
> To: [email protected]
> Subject: RE: st: RE: How to construct a duration variable?
>
> Good point. Drat.
>
>
>
> At 04:05 PM 4/6/2006, you wrote:
> >Not so. Each person can have one or more
> >spells on each -Brand-. Your code lumps
> >them all together.
> >
> >Nick
> >[email protected]
> >
> >Nick Winter
> >
> > > I think
> > >
> > > bysort hhid Brand: gen Duration=_N
> > >
> > > should do it.
> > >
> > > --Nick Winter
> > >
> > > At 01:42 PM 4/6/2006, you wrote:
> > > >Thank you, Nick.
> > > >
> > > >For example, there are three brands in the market: A, B and C.
> One
> > > >consumer buy A at the first period. At the second period, she
> > > >switches to B. Since then, she keeps buying B for the next four
> > > >periods. After that, she switches to C etc.
> > > >
> > > >Then the duration variable I want should be:
> > > >
> > > >hhid Period Brand Switch Duration
> > > >1 1 A 0 1
> > > >1 2 B 1 4
> > > >1 3 B 0 4
> > > >1 4 B 0 4
> > > >1 5 B 0 4
> > > >1 6 C 1 2
> > > >1 7 C 0 2
> > > >1 8 A 1 1
> > > >1 9 B 1 4
> > > >1 10 B 0 4
> > > >1 11 B 0 4
> > > >1 12 B 0 4
> > > >1 13 C 1 2
> > > >1 14 C 0 2
> > > >
> > > >I wish that it's clear this time. I just not sure how
> to construct
> > > >the duration variable in Stata.
> >
> >
> >*
> >* 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/
>
> ________________________________________________________
> Nicholas J. G. Winter 607.255.8819 t
> Assistant Professor 607.255.4530 f
> Department of Government [email protected] e
> Cornell University falcon.arts.cornell.edu/nw53 w
> 308 White Hall
> Ithaca, NY 14853-4601
>
>
> *
> * 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/
>
>
> This message is intended solely for the designated
> recipient(s). It may contain confidential or proprietary
> information and may be subject to confidentiality
> protections. If you are not a designated recipient, you may
> not review, copy, or distribute this message. If you receive
> this in error, please notify the sender by reply e-mail and
> delete this message.
>
> Arrowstreet Capital, L.P. is an Equal Opportunity Employer.
>
>
>
> *
> * 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/
>
*
* 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/