Statalist


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

Re: st: Counter Variable


From   Eva Poen <eva.poen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Counter Variable
Date   Sat, 2 May 2009 14:12:10 +0100

<>

bys id (sch) : gen princ = sum(new)
bys id princ (sch) : gen tenure = _n

Hope this helps,
Eva

2009/5/1 Meryle Weinstein <meryle.weinstein@nyu.edu>
>
> I have a dataset that is set up as
>
>  Id    schlyr   new_pr~c
>  A       1          1
>  A       2          0
>  A       3          0
>  A       4          0
>  A       5          0
>  A       6          0
>  A       7          0
>  A       8          0
>  A       9          0
>  A      10          0
>  A      11          0
>  B       1          1
>  B       2          0
>  B       3          0
>  B       4          0
>  B       5          0
>  B       6          0
>  B       7          0
>  B       8          0
>  B       9          0
>  B      10          1
>  B      11          0
> Etc.
>
> I want to create a new variable that is the number of years of principal
> tenure at each school based on the schoolyear and newprinc.  The counter
> should start again at 1 if new principal is 1 and go for the number of years
> until the new principal.
>
> Can't figure out the correct syntax to do this.  Any help is appreciated.
>
>
> Meryle Weinstein, Ph.D.
> Assistant Director
> Institute for Education & Social Policy
> New York University
> 82 Washington Square East, 7th floor
> New York, NY 10003
> (212) 9985817
> (212) 9954564 (fax)
> www.steinhardt.nyu.edu/iesp
>
>
>
>
> *
> *   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/

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



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