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

Hii all,

i have a data like 

Empid Description
101 A,B,C,D
102 E
103 D,E,F
104 K
105 X,Y,Z

 and I want the output like

Empid Description
101 A
101 B
101 C
101 D
102 E
103 D
103 E
103 F
104 K
105 X
105 Y
105 Z

 The description is having any "," then devide that row into multiple(if comma is there between the text).

 

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
slchen
Lapis Lazuli | Level 10


data have;
x="A,B,C,D";output;
x="B&C"; output;
x="E,F;C";output;
run;

 

data want;
set have;
do i=1 by 1;
_x=scan(x,i);
if missing(_x) then return;
output;
end;
drop x;
run;

View solution in original post

3 REPLIES 3
FreelanceReinh
Jade | Level 19

Try this:

data want;
set have(rename=(description=d));
length description $1; /* If your real items are not single characters, specify a sufficiently large length! */
do i=1 to countw(d, ',');
  description=scan(d, i, ',');
  output;
end;
drop d i;
run;
Ravikumarkummari
Quartz | Level 8

Could you suggest me if description column is having special characters then 

ex;  A,B,C,D

       B&C

     E,F;C

 

slchen
Lapis Lazuli | Level 10


data have;
x="A,B,C,D";output;
x="B&C"; output;
x="E,F;C";output;
run;

 

data want;
set have;
do i=1 by 1;
_x=scan(x,i);
if missing(_x) then return;
output;
end;
drop x;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1706 views
  • 0 likes
  • 3 in conversation