Subscribe Bookmark RSS Feed

Combining values of multiple columns into one column


Community Trekker


Nov 30, 2013

I have a data set where I would like to merge four columns  into one column, so that

the values of the four columns are displayed in one column. However, I have no clue how to do that.

I have four conditions, which respondents have been exposed to depending on the day of the month

they are born. If a respondent has been exposed to Condition 1 it shows a 1 and the same for

conditions 2,3, and 4. How can I easily recode the 1's of each column into names and then merge the

four columns into one column?


4584_Screen Shot 2013-11-30 at 11.53.23.png


Super User


Jun 23, 2011

Combining columns is not hard - you can use a column formula.  However I'm having difficulty understanding exactly what you want to do.  Can you provide a little more data, and what you want the final output to look like?


Community Member


Nov 27, 2012

If you want to re-code the 1's into names, you would make new columns that have the re-coded values for yourself, then simply merge all the data together using cat, ||, etc.. There are many ways to concatenate in sas..

So for example, see the (untested) code below.

Data answer(drop=Variable1new--Variable4New);

set have;

if Variable1=1 then Variable1New="YOUR TEXT";

if Variable2=1 then Variable2New="YOUR TEXT";

if Variable3=1 then Variable3New="YOUR TEXT";

if Variable4=1 then Variable4New="YOUR TEXT";

FinalVariable=Catx(',', of Variable1New--Variable4New);


Look into the catx function since I don't have it memorized.

Is this what you are looking for?


Community Manager


Jun 23, 2011

I think @Nikolaj is looking for a JMP solution, so the SAS data step code from while correct isn't going to help.

I agree with that this isn't hard with a column formula but we need some more information about the data that you have and what you'd like to end up with.



Community Trekker


Nov 30, 2013

Thank you for your responses. I figured it out.

Another question: When I run a test for variance homogeneity I get a Welch's test after the levene's test, brown-forsythe etc. Can someone explain what exactly the Welch's test shows?