Statalist


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

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


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

On my Stata 10.1 this is in help for -whatsnew7to8-. In bw's Stata, I
guess it's in help for -whatsnew7to8- too. 

    Stata now has multiple missing values!  In addition to the
    previously existing ., there is now .a, .b, ..., .z, and you
    can attach value labels to the new missing codes!

    One thing to watch out for:  Do not type

        . stata_command ... if x != .

    Instead, type

        . stata_command ... if x < .

    You need remember this only if you use the new missing values,
    but better to have good habits.  The way things now work,

        all numbers < . < .a < .b < ... < .z

    So, if you wanted to list all observations for which x is
    missing, you would type

        . list if x >= .

    See help missing.

Nick 
[email protected] 

Nick Cox

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