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

From |
Ilona Carneiro <ilonac@orange.es> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: AW: st: AW: Problem looping over spells for an individual |

Date |
Wed, 25 Feb 2009 18:23:43 +0100 |

My data is stset not tsset - so can't use the rolling feature. Ilona On 25 Feb 2009, at 17:59, Martin Weiss wrote:

<>Well, the "__000000" thing is the internal name for the temp youcreated. Iwanted to point out that this compares the FIRST observation and its"touse"value. If the first value of "touse" is one, then this statement istrue,otherwise false. Maybe that is what you want, maybe not... ************* sysuse auto, clear if mpg>20{ di in red "MPG bigger than 20" } if mpg>25{ di in red "MPG bigger than 25" } list mpg in 1 ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von IlonaCarneiroGesendet: Mittwoch, 25. Februar 2009 17:51 An: statalist@hsphsun2.harvard.edu Betreff: Re: st: AW: Problem looping over spells for an individual HI Martin I tried checking this before, but I didn't know how to interpret it. With tr: byid I get: if __000000 { But I don't know what that means? Ilona On 25 Feb 2009, at 17:39, Martin Weiss wrote:<> Are you sure the line ************* if `touse' { ************* does what you want it to? -set trace on- or indeed use the recently announced -ssc d tr- and report what happens... HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Ilona Carneiro Gesendet: Mittwoch, 25. Februar 2009 17:24 An: statalist@hsphsun2.harvard.edu Betreff: st: Problem looping over spells for an individual Hello all I am trying to write a programme that will run a command sequentiallyfor observations of an individual. For each individual I havemultiplespells and multiple failures. However, the twist is that I also needto 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 aprior treatment or episode) I don't want it to disqualify asubsequentepisode. 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: program define byid, byable(recall, noheader) marksample touse sort `id' `start' if `touse' { forvalues i = 1(1)`=_N' { replace lagend = (`end' + `lag') if ((`tx' > 0 & `tx' < .) | (`case'0 & `case' < .))drop if lagend[`i'-1]>`end' & `id'[`i'-1]==`id' } } end gen lagend=. qui by id: byid but I get the error: 2nd by group not found r(111); And the programme isn't doing what I need it to. Any ideas? Ilona * * 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/* * 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/

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

**Follow-Ups**:**RE: AW: st: AW: Problem looping over spells for an individual***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: Problem looping over spells for an individual***From:*Ilona Carneiro <ilonac@orange.es>

**st: AW: Problem looping over spells for an individual***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: st: AW: Problem looping over spells for an individual***From:*Ilona Carneiro <ilonac@orange.es>

**AW: st: AW: Problem looping over spells for an individual***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**st: AW: RE: Problem looping over spells for an individual** - Next by Date:
**RE: st: AW: simple "graph twoway, b()" question** - Previous by thread:
**AW: st: AW: Problem looping over spells for an individual** - Next by thread:
**RE: AW: st: AW: Problem looping over spells for an individual** - Index(es):

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