Friday, November 11, 2016

~= vs != Operators in Stata [Data]


The help page via invoking "help operator" in Stata suggests the two operators are the same. I wondered because sometimes operators do odd things. For example. 
 sysuse auto
 replace mpg = . If mpg == 22
 count if mpg > 0
 * output: 74
 count if mpg > 0 & mpg != .
 * output: 69
 count if mpg < 9999
 * output: 69 
What the example shows is that the ".", which represent missing, is a very large number to COUNT and not a NaN as most people would expect. Things works fine with SUM, however.