## Concatenate into single row!!!

Solved
Regular Contributor
Posts: 171

# Concatenate into single row!!!

Hi All,

Data have;

input id    mut \$;

cards;

100    mut1

100    nomut

100    mut3

101    mut3

101    mut4

105    mut5

105    nomut

105    mut6

;

run;

i want like this

100           mut1/nomut/mut3

101           mut3/mut4

105           mut5/nomut/mut6

Sam

Accepted Solutions
Solution
‎11-15-2012 01:56 PM
PROC Star
Posts: 8,163

## Re: Concatenate into single row!!!

Here is one way to do it, but this would leave it up to you to specify the length needed to capture the new field:

data want (drop=mut);

set have;

by id;

length newfield \$100;

retain newfield;

if first.id then newfield=mut;

else newfield=catx('/',newfield,mut);

if last.id then output;

run;

All Replies
Solution
‎11-15-2012 01:56 PM
PROC Star
Posts: 8,163

## Re: Concatenate into single row!!!

Here is one way to do it, but this would leave it up to you to specify the length needed to capture the new field:

data want (drop=mut);

set have;

by id;

length newfield \$100;

retain newfield;

if first.id then newfield=mut;

else newfield=catx('/',newfield,mut);

if last.id then output;

run;

Regular Contributor
Posts: 171

## Re: Concatenate into single row!!!

Thank you so much Art!!!!

🔒 This topic is solved and locked.