Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: different handling if missings in programs using syntax varlist [if}


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: different handling if missings in programs using syntax varlist [if}
Date   Thu, 21 Apr 2011 23:10:57 +0100

I see no puzzle here. In your -foo-, the variable -comment- was
created without reference to -price-. In fact, the rest of the program
had no bearing on that. So, no values were missing.

In -foobar-, things were different. Observation with missing -price-
were excluded.

Sorry, but what's the question here?

Nick

On Thu, Apr 21, 2011 at 10:55 PM, Bjorn Van Campenhout
<bjorn.vancampenhout@gmail.com> wrote:
> Dear statalist,
>
> I have observed different outcomes when I have missing observations in
> programs that use the if qualifier. I was wondering what logic is behind
> this.
> Here is a self-contained example:
>
> sysuse auto
>
> replace price=. if foreign==1
>
> cap pro drop foo
> pro def foo
>  syntax varlist
>  gen comment="this is only a test"
> end
>
>
>
> cap pro drop foobar
> pro def foobar
>  syntax varlist [if]
>  marksample touse
>  gen comment="this is only a test" if `touse'
> end
>
> foo price
> drop comment
> foobar price
>
> For those who wonder, I am trying to make a program that reports missings
> and want to be able to use conditions in my function calls.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index