Statalist The Stata Listserver


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

Re: st: data management


From   "[email protected]" <[email protected]>
To   [email protected]
Subject   Re: st: data management
Date   Mon, 26 Mar 2007 21:28:17 +0200

Thank you Carole,

it works very well. I tried several solutions by myself but I was far
away from 
fixing the problem - I really appreciate!

Simon


-----Original Message-----
Date: Mon, 26 Mar 2007 19:13:55 +0200
Subject: st: data management
From: "Carole J. Wilson" <[email protected]>
To: [email protected]

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/



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