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

st: RE: Rearranging dates for multiple records


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Rearranging dates for multiple records
Date   Thu, 22 Jul 2004 12:25:32 +0100

I don't understand either your data structure -- 
do you really mean nine _variables_ with dates -- 
or the logic of your record structure, as 
the numbering seems awry. 

Perhaps you mean something like this 

username   recordno   date 
1      0      <entry date> 
1      1      <first obs> 
...
1      9      <ninth obs> 
1      10       <exit date> 
2      0      <entry date> 

in which case 

. bysort username (recordno): gen date2 = date[_n+1] 

is most of what you want. 

Nick 
[email protected] 

Hannah Moore
 
> Hello, I am a relatively new STATA user.
> In my dataset I  have multiple records for every individual according 
> to how many observations they have had. Each individual is identified 
> by a username and within each username each record is identified by a 
> unique number starting from 0, 1, 2, etc up to 9. I also have up to 9 
> variables that are dates of the observations, plus an entry date into 
> the study and an exit date.
> 
> What I would like to do is for every individual, create an "entry" 
> variable and an "exit" variable that is for
> 
> the first record: entry   = entry date , exit = date observation 1
> second record: entry  = date observation1, exit = date observation3
> third record: entry = date observation3, exit  = date observation4
> etc etc
> until the last record: entry  = date last observation, exit = 
> exit date
> 
> Can anyone help me? The observations are also of 2 types and I would 
> also like to create variables in a similar fashion to "entry" and 
> "exit" according to what type of observation it is.

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