Bookmark and Share

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 multiple choice (string) response options to numeric values


From   David Kantor <[email protected]>
To   [email protected]
Subject   Re: st: converting multiple choice (string) response options to numeric values
Date   Fri, 07 Feb 2014 14:09:22 -0500

At 06:30 AM 2/7/2014, Nick Cox wrote:
This is quite a common problem, and it's easy to get bitten.

label def mylabels 1 "A" 2 "B" 3 "C" 4 "D" 5 "E"

foreach v of var <varlist> {
     encode `v', gen(n_`v') label(mylabels)
}

is a sketch of how to do it. You must replace <varlist> by an actual varlist.

Alternatively, as said, look at -multencode- (SSC).
[...]

I would add that the -noextend- option on encode may be desirable. It assures that no unexpected values are found among the original textual values. By default, they would get added to the label in the order received, which may not be desirable.

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index