Solved

sas-transpose the rows

Posted on 2012-04-02
1
240 Views
Last Modified: 2012-04-20
Hi,
I have table which looks like

table1
wc_id email
101    aa@yahoo.com
101    bb@yahoo.com
102    cc@yahoo.com
203    dd@yahoo.com

i want the results as
wc_id email
101    aa@yahoo.com;bb@yahoo.com
102    cc@yahoo.com
203    dd@yahoo.com

Thanks
0
Comment
Question by:sam2929
1 Comment
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 500 total points
ID: 37799183
you are not looking at transpose actually, but more of a data step processing:

data [[i]output[/i]] (drop=email rename=(new_email = email));
	set [[i]input[/i]];
	length new_email $200.;
	retain new_email;
	by wc_id;

	if first.wc_id then do;
		new_email = email;
	end;
	else do;
		new_email = trim(left(new_email)) || ";" || trim(left(email));
	end;

	if last.wc_id then output;
run;

Open in new window


of course, you can use PROC TRANSPOSE to perform the transpose but you'll get multiple columns. then from there, you'll need further processing (even more coding than above, trust me) to get your desired results...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now