12-03-2014 11:31 AM
I am trying to combine multiple 0/1 column variables in to one general column variable. Example: Multiple column data for race such as White, Black, etc. and they are all 0/1. What would be the best way to change them into a single column data variable? Any help is much appreciated!
12-03-2014 11:35 AM
It's really hard to understand what you want.
For example, do you want the 0s and 1s in variable White to be combined with the 0s and 1s in Black combined with the 0s and 1s in Hispanic etc.?
What should the output variable look like in this case? Concatenation of zeros and ones? An integer representing the category?
12-03-2014 12:09 PM
After that sort of a change, this might do the trick:
race = max(white, black, hispanic, asian, other);
But the cautions about inspecting and understanding what is in your data still apply.
12-03-2014 12:20 PM
Astounding thank you for getting back to me!
To answer your previous question: There does seem to be missing data in some of the variables. There are no multiple answers for multiple variables.
The max(var) did not work.
12-03-2014 12:50 PM
I'm still not really clear on what your data looks like now, and what you want it to look like when you are done.
I note that all of your explanations have great brevity, but that's not really what's needed here. We need details, we need an actual example or two (not words, but actual examples of part of the data set that you are working with).
12-03-2014 11:39 AM
The best way is to thoroughly examine what is in your data first. Here are some questions to get started.
1. Is there always an answer to every question, or are there some blanks in addition to the 0/1 values?
2. Does Race have an "other" question? If so, does it have an open-ended explanation? How would you like to handle that?
3. Does anyone check multiple answers, such as both "Black" and "White"?
The "best way" could easily change, depending on your answers to these questions.
12-03-2014 11:49 AM
And a long shot response: if this data originated in some survey software, possibly other sources, examine the export options and consider re-exporting. Some software will allow output of multiple dichotomous variables for choices or a single code. Like I say, long shot.