Statalist


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

st: programming, block-wise maxima


From   Jochen Späth <[email protected]>
To   <[email protected]>
Subject   st: programming, block-wise maxima
Date   Mon, 13 Jul 2009 18:07:05 +0200

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/



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