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   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: converting multiple choice (string) response options to numeric values
Date   Fri, 7 Feb 2014 19:17:11 +0000

<>

Excellent point.

Of course, looking at a -summarize- or something else beforehand would
help too. Other tools include -groups- (SSC), -tabm- from -tab_chi-
(SSC).
Nick
[email protected]


On 7 February 2014 19:09, David Kantor <[email protected]> wrote:
> 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/
*
*   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