Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: different n's using "if"


From   "Nick Winter" <nwinter@policystudies.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: different n's using "if"
Date   Thu, 31 Oct 2002 17:51:33 -0500

> -----Original Message-----
> From: Sarah A. Mustillo [mailto:smustillo@psych.mc.duke.edu] 
> Sent: Thursday, October 31, 2002 4:26 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: different n's using "if" 
> 
> 
> Hi -
> 
> This question is probably an easy one, but I am baffled...
> 
> I am trying to run GEE models for subsets of my sample 
> separately: white 
> girls, black girls, white boys, and black boys.  I have been 
> using an "if" 
> statement before the comma in the regression model, e.g., if 
> sex==0&race==1, etc.  I should also mention that I am 
> limiting the sample 
> by time of observation as well, so what I really have is: if 
> sex==0&race==1&period==1|2, for example.  I started getting 
> suspicious that 
> I wasn't doing what I wanted to do when my sample size stayed 
> large.  So, I 
> tried preserving the data set, the dropping male and black 
> and running the 
> model again, and the n was much smaller.
> 
> My question:
> 
> Shouldn't using "if" before the comma accomplish the same 
> thing as dropping 
> those people from the sample?  What am I missing?
> Below are my examples:
> 
> 
>  xi: xtgee pul    per2Xlagccm period2 lagccm age if 
> sex==0&racewh==1&period==1|2 [pweight=wt], robust corr(exch)

You've got a problem with your "period==1|2".  It needs to be (with
spaces to make things easier to read:

	sex==0 & racewh==1 & (period==1 | period==2)

YOu can't do "something==this|that"; you need to do "something==this |
something==that",
or use the inlist function:  inlist(something,this,that).

Your confusing results occurs because Stata is evaluating:

	(sex==0&racewh==1&period==1) | (2)

and (2) is always true.

--Nick Winter
 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index