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

From |
"B. Timothy Walsh" <btw1@columbia.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: AW: "skipping" missing data |

Date |
Thu, 06 Aug 2009 13:16:35 -0400 |

Thank you: this worked very nicely.

egen group = group(ptnum) if !missing(bperwk_, wk) Thanks again! Tim

Here is one of several alternatives. generate p1=. egen group = group(ptnum) if !missing(bperwk_, wk) summarize group, meanonly forval i = 1/`r(max)' { regress bperwk_ wk if group == `i' predict p replace p1=p if group == `i' drop p } That sets the missings on one side. See also: FAQ . . . . . . . . . . Making foreach go through all values of a variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox 8/05 Is there a way to tell Stata to try all values of a particular variable in a foreach statement without specifying them? http://www.stata.com/support/faqs/data/foreach.html Despite the reference to -foreach- the FAQ is still pertinent. Nick Martin Weiss wrote:************* capture ************* You could put it in front of individual commands, or the entire -forvalues- loop.B. Timothy WalshI am attempting to generate predictions from regressions performed for each of a longish list of individuals. The problem is that, for some individuals, there are no dependent variable data (entries are missing), so the regression attempt fails. The problem is that the forvalues loop then exits. I would like to somehow "skip" these individuals. Loop seems to work fine if there are enough data to perform a regression. I'd be grateful for any suggestions. Here's the code: generate p1=. forvalues i = 1/50 { //50 individuals regress bperwk_ wk if ptnum == `i' predict p replace p1=p if ptnum == `i' drop p } I'm pretty much a Stata novice. So, I apologize if I am missing something obvious. Using version 10.1.* * 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: st: AW: "skipping" missing data***From:*Nick Cox <n.j.cox@stata.com>

**References**:**st: "skipping" missing data***From:*"B. Timothy Walsh" <btw1@columbia.edu>

**st: AW: "skipping" missing data***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: st: AW: "skipping" missing data***From:*Nick Cox <n.j.cox@stata.com>

- Prev by Date:
**Re: st: Standard normal Depvar** - Next by Date:
**st: Panel data regression** - Previous by thread:
**Re: st: AW: "skipping" missing data** - Next by thread:
**Re: st: AW: "skipping" missing data** - Index(es):

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