Statalist


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

st: RE: numbering observations when variables change


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: numbering observations when variables change
Date   Tue, 23 Sep 2008 17:34:29 +0200

-h egen, group()-


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Fabian Brenner
Sent: Tuesday, September 23, 2008 5:33 PM
To: [email protected]
Subject: st: numbering observations when variables change

Dear all,

I want to use variable "id" to number observations. Whenever "name" or
"year" changes, "id" should increase by 1. I have sorted the data by name
and year (-sort name year-). I tried to solve the problem by -bysort name
year: generate id=_N- but it did not work.

Hopefully someone can help me.

Regards,
Fabian

Example:
"id"       "name"    "year" 
1         A            1990
1         A            1990
2         A            2001
3         B            2001
4         B            2003
5         B            2007
5         B            2007       
6         C            2007

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal f�r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index