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]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

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 <njcoxstata@gmail.com> 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, <Robert.Shaw@dh.gsi.gov.uk> 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/

**References**:**st: replacing zero length strings with missing values***From:*Robert.Shaw@dh.gsi.gov.uk

**Re: st: replacing zero length strings with missing values***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**RE: st: twoway line** - Next by Date:
**st: Twoway line** - Previous by thread:
**Re: st: replacing zero length strings with missing values** - Next by thread:
**Re: st: replacing zero length strings with missing values** - Index(es):