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]
st: RE: converting string to numerals
From
Joe Canner <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: converting string to numerals
Date
Wed, 20 Nov 2013 19:14:48 +0000
Ramesh,
-encode- sorts the responses in alphabetical order before converting to numeric, so if you can add something to the beginning of the string that will sort them correctly, that is one solution. However, if you are going to go through all that trouble, you might as well just use a series of -replace- statements to convert the strings to the desired numerals.
Regards,
Joe Canner
Johns Hopkins University School of Medicine
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of ramesh
Sent: Wednesday, November 20, 2013 2:08 PM
To: [email protected]
Subject: st: converting string to numerals
Hello statalist,
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?
Thanks,
Ramesh
--
View this message in context: http://statalist.1588530.n2.nabble.com/converting-string-to-numerals-tp7580454.html
Sent from the Statalist mailing list archive at Nabble.com.
*
* 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/