Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: How to numerate different events from the same person?


From   "Steichen, Thomas J." <[email protected]>
To   <[email protected]>
Subject   st: RE: How to numerate different events from the same person?
Date   Thu, 13 Oct 2005 10:58:58 -0400

Will this suffice:

   bysort patient: gen ing = _n

> I would like to assing to each discharge event of the same 
> patient a number. The first discherge will be number 1, the 
> second number 2 and so on.
> 
> This is the syntax I'm using. What's wrong with it? I don't 
> know why local values remained unchange.
> 
> input patient diag
> 1 8151
> 1 8006
> 1 8153
> 2 8154
> 2 8155
> 3 8005
> 3 8155
> end
> 
> gen lag_pat=patient[_n-1]
> replace lag_pat=patient if lag_pat==.
> 
> gen ing=1
> local j=1
> local N=_N
> forvalues i=1(1)`N'{
> 	if (_n==`i' & patient==lag_pat) {
> 		replace ing=`j'
> 		local j=`j'+1
> 	}
> 	else local j=1
> }
> 
> The result of this syntax was supposed to be:
> 
>      +--------------------------------+
>      | patient   diag   lag_pat   ing |
>      |--------------------------------|
>   1. |       1   8151         1     1 |
>   2. |       1   8006         1     2 |
>   3. |       1   8153         1     3 |
>   4. |       2   8154         1     1 |
>   5. |       2   8155         2     2 |
>      |--------------------------------|
>   6. |       3   8005         2     1 |
>   7. |       3   8155         3     2 |
>      +--------------------------------+
> 
> But I have obtained: 
> 
>      +--------------------------------+
>      | patient   diag   lag_pat   ing |
>      |--------------------------------|
>   1. |       1   8151         1     1 |
>   2. |       1   8006         1     1 |
>   3. |       1   8153         1     1 |
>   4. |       2   8154         1     1 |
>   5. |       2   8155         2     1 |
>      |--------------------------------|
>   6. |       3   8005         2     1 |
>   7. |       3   8155         3     1 |
>      +--------------------------------+
> 
> Could anyboby help me?
> 
> Thanks a lot
> 
> Alejandro Allepuz Palau
> Ag�ncia d'Avaluaci� de Tecnologia i Recerca M�diques
> Catalan Agency for Health Technology Assessment and Research 
> Recinte Parc Sanitari Pere Virgili c/ Esteve Terradas, 30, 
> Edifici Mestral, 1a planta 08023 Barcelona
> Tel: 34 - 93 259 42 17
> Fax: 34 - 93 259 42 01
> e-mail: [email protected]
> Web site: http://www.aatrm.net
> 
> > Aquest missatge s'adre�a exclusivament al seu destinatari i pot 
> > contenir informaci� privilegiada o confidencial. Si no sou el 
> > destinatari indicat, us recordem que la utilitzaci�, divulgaci� i/o 
> > c�pia sense autoritzaci� est� prohibida en virtut de la legislaci� 
> > vigent. Si heu rebut aquest missatge per error, us demanem 
> que ens ho 
> > feu saber immediatament per aquesta mateixa via i que procediu a 
> > destruir-lo.
> > 
> > Este mensaje se dirige exclusivamente a su destinatario y puede 
> > contener informaci�n privilegiada o confidencial. Si usted no es el 
> > destinatario indicado, le recordamos que la utilizaci�n, 
> divulgaci�n 
> > y/o copia sin autorizaci�n est� prohibida en virtud de la 
> legislaci�n 
> > vigente. Si ha recibido este mensaje por error, le rogamos 
> que nos lo 
> > comunique inmediatamente por esta misma v�a y que proceda a 
> > destruirlo.
> > 
> > This message is directed exclusively to its recipient and 
> can contain private or confidential information. If you are 
> not the indicated recipient, we remind you that the use, 
> distribution and/or copy without authorization is prohibited 
> by virtue of the current legislation. If you have received 
> this message by mistake, we ask you to inform us immediately 
> by e-mail and   destroy it.
> > 
> 
> *
> *   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/
> 

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the
attorney-client or other legal privileges, and/or proprietary non-
public information. If you are not an intended recipient of this
message or an authorized assistant to an intended recipient, please
notify the sender by replying to this message and then delete it from
your system. Use, dissemination, distribution, or reproduction of this
message and/or any of its attachments (if any) by unintended recipients
is not authorized and may be unlawful.


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



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