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: converting string to numerals
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: converting string to numerals
Date
Wed, 20 Nov 2013 19:15:32 +0000
-encode- does not understand English in the way that you do. My guess
is that it did not encode your values randomly at all, but as
1 agree
2 disagree
3 neither ...
4 strongly agree
5 strongly disagree
which is an alphabetical order.
What you need is covered by the syntax and documentation of -encode-,
namely to define your labels in advance:
label define mylabels -2 "strongly disagree" <and so forth>
encode var, gen(var1) label(mylabels)
while at the same time using more evocative variable names.
Nick
[email protected]
On 20 November 2013 19:07, ramesh <[email protected]> wrote:
I have a very basic question about coding string variables. My variable is
> expressed as strongly disagree, disagree, neither disagree nor agree, agree,
> and strongly agree. I want to code them -2 if strongly disagree, -1 if
> disagree, 0 if neither disagree nor agree, 1 if agree, and 2 if strongly
> agree. I used encode(var), gen(var1), but it coded the scales randomly. Is
> there any direct way to preserve the order in data coding?
*
* 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/