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]

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   st: different handling if missings in programs using syntax varlist [if}
Date   Thu, 21 Apr 2011 23:55:54 +0200

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.

Kind regards,
Bjorn
*
*   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