Statalist


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

st: RE: "if and &" expression in edit


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: "if and &" expression in edit
Date   Wed, 28 Jan 2009 19:04:32 -0000

Nothing to do with either -edit- or -if- or -&-. 

The problem, as declared, is a type mismatch. 

As -plannedsx- is float it can never be equal to an empty string. 

-if plannedsx < .- would be one good way to test whether it was not
missing. 

(I think Stata 8.2 had extended missing values .a ... .z already, so 

!= . 

and 

< . 

are not the same.) Tony Lachenbruch got a very useful publication in the
early STB out of explaining that < . was shorter than != . but with
extended missing values his short-cut really came into his own. 

STB-9   ip2 . . . . . . . . . . . . . . . . . . . . . . .  A keyboard
shortcut
        . . . . . . . . . . . . . . . . . . . . . . . . . .  P. A.
Lachenbruch
        9/92    p.9; STB Reprints Vol 2, p.46                    (no
commands)
        keyboard shortcut to indicate nonmissing values


Also, check out the -missing()- function. It may have been called
-miss()- in Stata 8.2. 

... if !missing(plannedsx) 

is how you could do it in Stata 10. 

Nick 
[email protected] 

b. water

Stata 8.2,

I wanted to do this:

edit if plannedsx!="" & modalit==""
 
i.e. i wanted to edit those where plannedsx are not missing but where
modality are missing
 
and received this message:
 
type mismatch
r(109);

The variables descriptions are:

              storage  display     value
variable name   type   format      label      variable label
------------------------------------------------------------------------
-------
plannedsx       float  %9.0g       planndsx     
modalit         byte   %1.0f       electrosx
                                            
Questions are:
 
1. How I can achieve what I wanted to do?
2. I would appreciate confirmation of this situation: I tried another
edit with if and & using another conditions and variables, these few
attempts returned the same type mismatch error r(109) - so I presumed
edit with if and & is not a legal syntax.


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index