Statalist


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

Re: st: Problem looping over spells for an individual


From   Michael Hanson <[email protected]>
To   [email protected]
Subject   Re: st: Problem looping over spells for an individual
Date   Wed, 25 Feb 2009 12:14:06 -0500

On Feb 25, 2009, at 11:24 AM, Ilona Carneiro wrote:

I am trying to write a programme that will run a command sequentially for observations of an individual. For each individual I have multiple spells and multiple failures. However, the twist is that I also need to exclude a period of time at risk after each treatment (prophylaxis) and after each failure (to prevent double- counting of failures that may actually be the same episode). I managed to do this without any problem for the treatment, but if an episode is disqualified (by a prior treatment or episode) I don't want it to disqualify a subsequent episode. Therefore I need to run the code sequentially for each spell of an individual, but using the marksample touse code to run it "by" individual doesn't seem to be working - the "forvalues" seems to always interpret _N as the last observation in the whole dataset, not the last observation for each individual.

I have the following code:

	[snip]

And the programme isn't doing what I need it to.

Any ideas?

I don't know enough about your data to know how relevant this suggestion may be, but have you looked into -rolling-?

HTH,
Mike

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