Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Combining values of multiple columns into one column

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Nov 30, 2013 3:01 AM
| Last Modified: Oct 18, 2016 1:29 PM
(12854 views)

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?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Dec 2, 2013 3:12 PM
| Last Modified: Sep 7, 2017 11:26 AM
(15113 views)
| Posted in reply to message from anotherdream 12-02-2013

How can I easily recode the 1's of each column into names and then merge the four columns into one column?

You've asked a two-part question.

1) How do I recode the 1's into names? For this you can use Recode.

2) How do I merge four columns into one column? For this you need a Formula, using the Concat function or operator.

-Jeff

5 REPLIES 5

Highlighted
##

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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Combining values of multiple columns into one column

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Combining values of multiple columns into one column

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);

run;

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

Is this what you are looking for?

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Dec 2, 2013 3:12 PM
| Last Modified: Sep 7, 2017 11:26 AM
(15114 views)
| Posted in reply to message from anotherdream 12-02-2013

How can I easily recode the 1's of each column into names and then merge the four columns into one column?

You've asked a two-part question.

1) How do I recode the 1's into names? For this you can use Recode.

2) How do I merge four columns into one column? For this you need a Formula, using the Concat function or operator.

-Jeff

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Combining values of multiple columns into one column

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?

Highlighted
##

Welch is a t-test for instances where the homogeneity of variance assumption is violated. most ppl would prefer to use a non-parametric test for this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Combining values of multiple columns into one column

Article Labels

There are no labels assigned to this post.