BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vjpkr
Calcite | Level 5

eg : I have  5 names under the column "User" in a dataset, how do I get the result as  AB;BC;CD;DE;EF where AB,BC,CD,DE,EF are the values under the column "User" .

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Like this:

data have;
input user :$2.;
datalines;
AB
BC
CD
DE
EF
;

data want(keep=userList);
length userList $24;
do until(eof);
     set have end=eof;
     userList = catx(";", userList, user);
     end;
run;

proc print data=want noobs; run;

PG

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Like this:

data have;
input user :$2.;
datalines;
AB
BC
CD
DE
EF
;

data want(keep=userList);
length userList $24;
do until(eof);
     set have end=eof;
     userList = catx(";", userList, user);
     end;
run;

proc print data=want noobs; run;

PG

PG
mgrd
Calcite | Level 5

I'd like to know, how it's possible to concatenate one column and mantain the information in each row. For example:

A B

a 1

a 2

a 3

b 4

b 5

b 6

c 7

d 8

e 9

e 10

f 11

 

Create 3 columns like this:

A    B     Concatenate

a    1     1,2,3

a    2     1,2,3

a    3     1,2,3

b    4     4,5,6

b    5     4,5,6

b    6     4,5,6

 

 

Thanks in advance for your help!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 8929 views
  • 1 like
  • 3 in conversation