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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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