Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: data management


From   "Carole J. Wilson" <[email protected]>
To   [email protected]
Subject   st: data management
Date   Mon, 26 Mar 2007 12:13:55 -0500

Simon,

You should edit the temp2 line in the loop to read:

gen temp2=1 if entry<exit[`i'] & exit>exit[`i']

if you want to exclude have cases of 6's that enter after `i' and exit
before `i'.  Again you may wish ">=" depending on how you wish to deal
with exits that occur in the same time period as `i'.

--Carole


gen temp1=(size==6)
gen new=.
local n=_N
qui forvalues i = 1/ `n'  {
       capture drop temp2
       capture drop temp3
       gen temp2=1 if entry<exit[`i']
       egen temp3=sum(temp1) if temp2==1
       replace new=temp3 in `i'
}
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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