BookmarkSubscribeRSS Feed
Sandhya
Fluorite | Level 6
Hi,

I have a dataset like

anlt lbno

aaa 1
aaa 2
aaa 4
bbb 2
bbb 3
bbb 4
ccc 1
ccc 2
ccc 3
ccc 4

I want it to be printed in excel as

anlt lbno

aaa 1, 2, 4
bbb 2, 3, 4
ccc 1, 2, 3, 4

Thanks in advance,
Sandhya.
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Use PROC TRANSPOSE to create a new SAS file and then use a DATA step to concatenate (using CATX function) the transposed values.

Scott Barry
SBBWorks, Inc.
Patrick
Opal | Level 21
The solution below uses SAS/ACCESS for PC Files. In case there is no license for this module: Create a csv file.

HTH
Patrick

data have;
infile datalines;
input anlt $ lbno;
datalines;
aaa 1
aaa 2
aaa 4
bbb 2
bbb 3
bbb 4
ccc 1
ccc 2
ccc 3
ccc 4
;
run;

libname outxls excel 'c:\temp\want.xls' ;
data outxls.wantsheet(keep=anlt lbno_str);
set have;
by anlt;
retain lbno_str;
length lbno_str $ 100;
if first.anlt then
lbno_str=cats(lbno);
else
lbno_str=cats(lbno_str,',',lbno);
if last.anlt then
output;
run;

libname outxls;
Sandhya
Fluorite | Level 6
Thank you. It was very helpful.

Sandhya.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1257 views
  • 0 likes
  • 3 in conversation