Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: managing data


From   "David Elliott" <[email protected]>
To   [email protected]
Subject   Re: st: managing data
Date   Thu, 4 Dec 2008 17:29:30 -0400

It is unclear from your example what you are trying to accomplish.

In your example, is event a summary count?  If so, I can't reconcile the

old database:
id event x
1  1      30
2  1      15
2  2      15

with what you have in

new database
id event x
1  1      30
1  1      30
2  1      15
2  2      15

You could (almost) create your new database from the old using
-fillin id event-

this would give you:

    +---------------------------+
     | id   event    x   _fillin |
     |---------------------------|
  1. |  1       1   30         0 |
  2. |  1       2              1 |
  3. |  2       1   15         0 |
  4. |  2       2   15         0 |
     +---------------------------+

then
-replace x=x[_n-1] if _fillin-

would give you:

    +---------------------------+
     | id   event    x   _fillin |
     |---------------------------|
  1. |  1       1   30         0 |
  2. |  1       2   30         1 |
  3. |  2       1   15         0 |
  4. |  2       2   15         0 |
     +---------------------------+

however, event in row 2 is a '2' rather than a '1' which may defeat
your purpose.

Look at -help fillin- and -help expand- and consider the possibility
of doing something with -bysort id:- depending on the value of _N.

Anyhow, a more complete example would be helpful.

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



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