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 at the end of May, 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   Bjorn Van Campenhout <bjorn.vancampenhout@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: different handling if missings in programs using syntax varlist [if}
Date   Fri, 22 Apr 2011 12:46:20 +0200

Thanks Nick, for explaining the logic behind this apparent difference in behaviour:

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.

Thanks Daniel, for pointing out the option -novarlist- to -marksample-, where it clearly states:
	
	You should also specify novarlist when missing values are not to cause
        observations to be excluded (perhaps you are analyzing the pattern of missing
        values).


It now works as I 'expected':

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, novarlist
  gen comment="this is only a test" if `touse'
end

foo price
drop comment
foobar price

Thanks,
Bjorn



On 04/22/2011 10:39 AM, Nick Cox wrote:
Also -nmissing- (SJ).

Nick

On Fri, Apr 22, 2011 at 9:24 AM, daniel klein
<klein.daniel.81@googlemail.com>  wrote:
By the way, regarding your plan to write a program reporting on
missings, you might want to take a look at -help misstable- if you are
not yet aware of this program.

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


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