Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Creating chronological event numbers
From
[email protected] (Brendan Halpin)
To
[email protected]
Subject
Re: st: Creating chronological event numbers
Date
Wed, 23 Mar 2011 09:48:35 +0000
On Wed, Mar 23 2011, Caroline Jackson wrote:
> I have a dataset, currently formatted long, which has multiple records
> (admissions to hospital) per unique id (i.e. per person). I want to
> create a new variable which uses the date of admission to assign a
> chronological admission number (i.e. 1,2,3...) to each separate
> person/id. So, effectively, I would end up with an event number for
> each hospital admission for each person.
If your date variable will sort correctly (e.g. 2011-03-23 not 23/03/11,
or a numeric date), this should work:
. sort id date
. by id: gen seqno = _n
Brendan
--
Brendan Halpin, Department of Sociology, University of Limerick, Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F1-009 x 3147
mailto:[email protected] http://www.ul.ie/sociology/brendan.halpin.html
*
* 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/