Bookmark and Share

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: replacing zero length strings with missing values


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: replacing zero length strings with missing values
Date   Tue, 4 Sep 2012 13:20:43 +0100

Should be

A string value is missing if and only if it is empty. (That is, the
function -missing()- returns 1 for true with string
arguments if and only if that string argument is empty.)

Nick

On Tue, Sep 4, 2012 at 1:15 PM, Nick Cox <[email protected]> wrote:
> You tried to replace empty strings with numeric missing . --  but, as
> you report here, that is a type mismatch.
>
> There is nothing to do here: empty strings and missing strings are one
> and the same in Stata. Consider
>
> . di missing("")
> 1
>
> . di missing(" ")
> 0
>
> . di missing("frog")
> 0
>
> A string value is missing if and only if it is empty. (That is, the
> function -missing()- returns 1 for true if and only with string
> arguments if and only if that string argument is empty.)
>
> It is possible to replace "" with "." if you wish to show empty
> strings explicitly, but that's all in the eye of the beholder: Stata
> does not regard "." as denoting string missing: it's just a stop or
> period character.
>
> Nick
>
> On Tue, Sep 4, 2012 at 12:54 PM,  <[email protected]> wrote:
>
>> I have a large dataset in stata and one of the variables has a lot a
>> observations that should be missing values but are instead zero length
>> strings (ie. =="")
>>
>> I've tried
>>
>> foreach x of varlist myvariable {
>> replace `x' = . if(`x' =="")
>> }
>>
>> but this gives a type mismatch.
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index