Bookmark and Share

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]

RE: st: Need Help with converting String Variables to Numeric Variables


From   "Dudekula, Anwar" <dudekulaan@upmc.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Need Help with converting String Variables to Numeric Variables
Date   Tue, 19 Jun 2012 02:38:11 +0000

Dear Nick and Daniel, 

Thanks a lot for the response.

Unfortunately, I have missing values in the original variable.

Hence the new variable generated with destring command and  force option generates new additional missing values  in addition to missing values generated corresponding  to the missing values in original variable 

The practical problem with this issues is that the original variable is a biomarker  and  a missing value is  being created for an observation like "<0.01" in original variable. 

In stata missing value is a huge number but infact this number should be equal to zero 

Is there a way around it .

Thank you,
Yours Sincerely,
Anwar 
________________________________________
From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] on behalf of Nick Cox [njcoxstata@gmail.com]
Sent: Monday, June 18, 2012 9:34 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Need Help with converting String Variables to Numeric Variables

I agree with Daniel. But I would check what is being mapped to zero.

destring numvar, force gen(strvar)
tab numvar if missing(strvar)

Nick

On Mon, Jun 18, 2012 at 11:58 PM, daniel klein
<klein.daniel.81@googlemail.com> wrote:

> Can't you just -destring- your string variable, specifying the -force-
> option, and -replace- the created missing values with 0 in the new
> variable? Or am I missing something here?

Anwar

> I am working on a data set of a hospital where  one of the variables
> has string values as observations .
>
> I am able to convert numeric string values to numeric values using
> destring command.
>
> But I have some of the observations as "< 4", "<0.04","less than 0.1"
> which needs to be converted to zero .
>
> In Stata we have option to convert nonmumeric values to missing values
> , but I need to convert them to Zero .

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


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index