You can also try:
gen newid = .
bysort id: replace newid = 1 if _n == _N
Francisco.
On Mon, Sep 8, 2008 at 8:35 AM, fjc fjc <[email protected]> wrote:
> Check help egen tag
>
> Francisco.
>
> On Mon, Sep 8, 2008 at 7:05 AM, Diddy Antai <[email protected]> wrote:
>> Hello,
>> Could you help me with the command that creates a new
>> variable "newid" that is 1 for the last observation for each
>> individual and missing otherwise.
>>
>> I have a dataset with multiple observations (mothers), and I want to
>> create a variable with each mother appearing once irrespective of the
>> number of children she has.
>> Thank you
>>
>> D
>>
>> *
>> * 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/