Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[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 <[email protected]>
To
[email protected]
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
<[email protected]> 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/