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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: RE: Problem identifying a specific value of a string variable


From   "Kieran McCaul" <Kieran.McCaul@uwa.edu.au>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Problem identifying a specific value of a string variable
Date   Fri, 10 Sep 2010 06:38:56 +0800

...

have you tried
egen x = group(col1_d)

This will give you a numeric variable, x, where each value corresponds to the string values of col1_d.  Then find the value of x that corresponds to 2e in col1_d.

 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Brad Humphreys
Sent: Friday, 10 September 2010 5:19 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: Problem identifying a specific value of a string variable

Dear Statalisters,

I have a string variable that I cannot seem to get Stata to perform
operations on.  This is part of a multiple step string to numeric
conversion. The string variable is col1_d

. desc col1_d

              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------------------
col1_d          str5   %9s

. tab col1_d

     col1_d |      Freq.     Percent        Cum.
------------+-----------------------------------
         2e |          1        0.00       29.09

The variable takes many values.  I have not reported the rest, as I
want to keep them. I can't get that observation, or about 10 more,
identified, using -list-, -drop-, or -replace-.  I tried:

. l if col1_d=="2e"

Returns nothing.  I tried:

. drop if col1_d=="2e"
(0 observations deleted)

I tried -trim-, -ltrim-, strltrim- on the variable, thinking there
could be leading blanks in there.  No luck.  I tried copying the
offending value for col1_d from the data editor into the do file
command.  No luck.  The variable col1_d is created using this command

gen col1_d=col1 if frac_col1==0

where col1 is a string variable.

. desc col1

              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------------------
col1            str10  %10s


Any help would be appreciated.   I am at wits end.

Brad Humphreys

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