<>
It does it well, conditional on there being only 1 observation per id to
begin with, which is not the case for -id==3-
l ,noo sepby(id)
+--------------------------+
| id begin end cens |
|--------------------------|
| 1 1997 2006 0 |
| 1 2006 . 1 |
|--------------------------|
| 2 1997 2003 0 |
| 2 2003 . 1 |
|--------------------------|
| 3 1997 2004 0 |
| 3 1997 . 1 |
| 3 2004 2007 0 |
| 3 2007 2007 0 |
|--------------------------|
| 4 1997 2006 0 |
| 4 2006 . 1 |
+--------------------------+
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Jeph Herrin
Gesendet: Mittwoch, 28. Oktober 2009 13:33
An: [email protected]
Betreff: Re: AW: st: add new record for individual in dataset
Then
expand 2
bys id : replace begin=end[1] if _n==2
bys id (begin) : replace end=. if _n==2
bys id (begin) : replace cens=1 if _n==2
will do it.
J
Martin Weiss wrote:
<>
Stata probably won`t like the line "bys id : replace begin[2]=end[1]" and
complain that "weights (are) not allowed"...
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Jeph Herrin
Gesendet: Mittwoch, 28. Oktober 2009 13:08
An: [email protected]
Betreff: Re: st: add new record for individual in dataset
Try
expand 2
bys id : replace begin[2]=end[1]
bys id (begin) : replace end[2]=.
bys id (begin) : replace cens[2]=1
hth,
Jeph
Marcus Casey wrote:
Hi,
Does anyone know how I can add a new record for an id in a long form
dataset?
Specifically , I have a dataset with the following structure
id begin end cens
1 1997 2006 0
2 1997 2003 0
3 1997 2004 0
3 2004 2007 0
4 1997 2006 0
and I want to add an additional record for each id in the following
manner
id begin end cens
1 1997 2006 0
1 2006 . 1
2 1997 2003 0
2 2003 . 1
3 1997 2004 0
3 2004 2007 0
3 2007 . 1
4 1997 2006 0
4 2006 . 1
Thanks in advance
Regards,
Marcus
*
* 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/
*
* 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/
*
* 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/