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: Tostring Question
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Tostring Question
Date
Mon, 16 Dec 2013 17:28:06 +0000
-tostring- is just a wrapper for -string()- and -string(.)- returns
".". If you want empty strings instead, add a line
replace byte_var = "" if byte_var == "."
But all this should be unnecessary. -egen, concat()- concatenates
numeric and string variables alike. If you are doing your
concatenation using +, OK, but Stata offers a solution.
Nick
[email protected]
On 16 December 2013 17:02, Erika Kociolek <[email protected]> wrote:
> Hi there,
>
> I am trying to convert a byte variable (byte_var) to a string so it
> can be concatenated with other variables. Sometimes this variable is a
> string when imported into Stata, and sometimes it is not (thus the
> "capture confirm" code). When I do this using the tostring command,
> for missing values of byte_var, I get "." instead of "" (missing).
>
> Here is the code I'm using:
>
> capture confirm numeric variable byte_var
>
> if !_rc {
> tostring byte_var, force replace
> }
>
> Any suggestions or assistance would be very helpful.
>
> Best,
> Erika
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/