Hello,
egen var=_n , by(group)
by group : replace var=var-1 if mod(var,2)==0
I think this should work.
What the second line says is that for every even number var should
have the value of the previous var which is itself -1 .
Can someone approve this ? I am not 100% certain.
Thank you,
Ashim.
On Wed, Nov 12, 2008 at 4:36 PM, Linn Renée Naper <[email protected]> wrote:
> Hi Statalist
>
> egen var=_n, by(group) will give me a variable counting from 1 til N within each group of the data.
> BUT: how do I tell stata that the observations are double in the sense that I need a variable that repeats each number ones,
> like this: 11 22 33 44.... instead of 1 2 3 4.....
> I need this variable in order to collapse the data.
>
> Thanks
>
> *
> * 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/