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/