Statalist


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

st: Re: Extended missing values from -destring-


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: Re: Extended missing values from -destring-
Date   Tue, 23 Jun 2009 00:00:52 +0900

Bert Jung wrote:

I have a string variable that contains mostly numbers but also
informative missing values like "dk" and "na".  I would like to
-destring- but retain the
cause for the missing values, i.e. produce extended missing values
such as .d and .n where appropriate.  -destring- apparently only
accommodates the system missing value ".".

I could write a few lines (e.g. copy into a second variable and then
replace) but wondered if there is a one-line way to coax -destring-
into producing these extended missing values?

--------------------------------------------------------------------------------

I'm not sure about a single line of code (unless someone has already written a
convenience module to do it), but you could do something like

replace var = "." + lower(substr(var, 1, 1)) ///
    if inrange(lower(substr(var, 1, 1,)), "a", "z")

and then -destring- the result.

Joseph Coveney



*
*   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