|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: AW: programming, block-wise maxima
<>
Here is the easy part:
*************
clear*
input panel_id entry year emp out1
1476902 1998 1998 28 0
1476902 1998 1999 7 0
1476902 1998 2000 0 0
1476902 1998 2001 0 1
1476902 1998 2002 0 0
1476902 1998 2003 0 0
1476902 1998 2004 0 2
1476902 1998 2005 15 0
end
compress
bys panel_id (year): egen /*
*/ out1_max=max((emp==0)*out1)
list, noobs
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Jochen Späth
Gesendet: Montag, 13. Juli 2009 18:07
An: [email protected]
Betreff: st: programming, block-wise maxima
Dear statalisters,
I'm stuck with a programming problem:
Suppose my data on business start-ups looks like this:
panel_id entry year emp out1
1476902 1998 1998 28 0
1476902 1998 1999 7 0
1476902 1998 2000 0 0
1476902 1998 2001 0 1
1476902 1998 2002 0 0
1476902 1998 2003 0 0
1476902 1998 2004 0 2
1476902 1998 2005 15 0
What I would like to have is a variable, say out1_max, that contains the
maximum value of out1 - but STATA is meant to search for that maximum value
only inside periods during which emp == 0. Furthermore, out1_max should
contain all missings (besides the respective maximum values which should
appear in the year following the last observation with emp == 0). I.e., the
overall result should look as follows:
panel_id entry year emp out1 out1_max
1476902 1998 1998 28 0 .
1476902 1998 1999 7 0 .
1476902 1998 2000 0 0 .
1476902 1998 2001 0 1 .
1476902 1998 2002 0 0 .
1476902 1998 2003 0 0 .
1476902 1998 2004 0 2 .
1476902 1998 2005 15 0 2
Any suggestions?
Thanks,
Jochen
*
* 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/