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: Fwd: Fastest way to identify values that start and end with a 9?
From
David Kantor <[email protected]>
To
[email protected]
Subject
Re: st: Fwd: Fastest way to identify values that start and end with a 9?
Date
Thu, 03 Oct 2013 10:48:19 -0400
On Thu, 3 Oct 2013, Evan DeFilippis wrote:
Values in my data set contain different numerical representations for
"Don't Know" and "Refusal"
A "Don't Know" will always start and end with a '9', but there can be
as many '9's in between as possible, up to the maximum length of a
string (244).
A "Refusal" will always start with a '9' and end with an '8', and
there can be as many '9's' in between as possible, up to the maximum
length of a string (244).
I haven't been following this from the beginning, but it strikes me
as similar to a situation that I have dealt with in the past -- and I
have code to deal with it (available, if you like).
My handling of the situation always...
1, requires a knowledge of the maximal number of digits for each
particular variable. That requires knowing some facts about the
encoding of each variable -- either from documentation or from
examining the data. Thus, if you specify 4 digits, the code looks for
values 9998 and 9999. In this case, for example, you would want to
recode 9998 to REF, but leave 998 as a legitimate value.
2, leaves the type as numeric (integer), and uses extended missing
values to represent the DK and REF values. (You can assign a value
label to cover these values.)
HTH
--David
*
* 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/