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: converting multiple choice (string) response options to numeric values
From
Katherine Picho <[email protected]>
To
[email protected]
Subject
st: converting multiple choice (string) response options to numeric values
Date
Thu, 6 Feb 2014 19:59:28 -0500
I have a huge dataset which has test data with multiple choice
questions. 2 questions have choices A -E, and the rest have 4 options
A-D
I was looking to convert these options to numeric values with A
corresponding to 1, B=2, etc.
I'm using stata 12.
I tried using the egen newvar= group (oldvar) command, it seems to
work for some questions but not others. For instance the sequence of
the 1st 5 students' answers for question 18 are AAAAA, which should
translate to 5 consecutive 1s..but I get consecutive 2s instead.
For another test question 10, a value of 6 is reported for one
observation which actually has a letter value of C which should
correspond to a value of 3.
I also tried encode oldvar, gen (newvar)
but I get the exact same variable data as in the original (i.e.
letters, not numbers) even though the data storage type now shows
'long'
I've checked to make sure there is consistency in data entry and there
appears to be; i.e. all responses are entered in capital letters, and
there is no mix of numeric and letters in the same variable/ column.
What am I doing wrong? Any thoughts on this problem would be highly
welcome as I dread the idea of having to manually convert these
letters to numbers!
thanks!
Katherine
*
* 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/