Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble reshaping a variable

    Hi there,

    My data is formatted in such a way that multiple choice questions that permitted multiple answers are listed as separate variables (ie. a question about race that allowed "choose all that apply" appears with each option in a different column: race1 is White, race2 is White, race3 is East Asian, etc.) I'm trying to combine the multiple race variables into a single variable. I've already renamed the current variables so that they have the same stubnames with different numeric suffixes.
    The code I tried was (where race is the stubname): reshape long race , i(id) But, this resulted in the creation of a single race variable that only includes one option (and all respondents have been assigned that single option). Where did I go wrong? Thanks in advance!

  • #2
    I doubt anybody can answer this question without seeing an example of the data set as it was before you did the -reshape-. Please post back with that, and be sure to use the -dataex- command for that purpose. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X