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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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