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

From |
Alexandra de Montrichard <ademontr@attbi.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: egen or other methods to calculate consecutive row totals? |

Date |
Mon, 03 Mar 2003 14:08:32 -0500 |

I am somewhat new to stata and I need some help with a problem I can't seem to resolve.

I am working with a database of students for whom I have quarterly grades for 5 years (1995-2000). I also have the start & completion date for a class that all students took a one point during those five year. I need to figure out how many quarters of grades I have for each student before & after they took this class & how many are consecutive quarters of grades. I've created a 0-1 variable for each quarter (0 if the student did not get any grades that quarter, 1 if they received a grade), converted the class start & exit date into quarter format & used egen to count of the number of quarters in which each student received grades

. egen byte gradenbr = neqany (grade951-grade004), v (1)

However, I now need to figure out a way of counting the number of quarters with grades both before & after the class as well as a way to know how many consecutive quarters with grade I have after completion of the class. I though I could use egen combined with if to create a gnbrpost variable of the number of quarters with grades after completion of the class:

. egen byte gnbrpost = neqany (grade951-grade004) if (exitdq== q(1995q1)), v (1)

. egen byte gnbrpost = neqany (grade952-grade004) if (exitdq== q(1995q2)), v (1)

. egen byte gnbrpost = neqany (grade953-grade004) if (exitdq== q(1995q3)), v (1) etc.....

but I can't figure out how to replace the gnbrpost variable each time I run a new egen calculation plus I'm sure there must be a better way of doing this, which would also allow me to know how many consecutive quarters of grades I have.

Thanks!

Alexandra de Montrichard

*

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

**Follow-Ups**:**st: RE: egen or other methods to calculate consecutive row totals?***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: RE: st: out-of-date commands** - Next by Date:
**st: RE: egen or other methods to calculate consecutive row totals?** - Previous by thread:
**Re: st: RE: Stata -list- (now graphics)** - Next by thread:
**st: RE: egen or other methods to calculate consecutive row totals?** - Index(es):

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