Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving multiple rows to single row

Status
Not open for further replies.

timppap

Technical User
Feb 10, 2006
7
SE
I have this kind of data

TiliA TiliB
A 1
A 2
A 3
B 1
B 2

I want to get like this

TiliA TiliB
A 1 2 3
B 1 2

How to do it ?
Thanks
 
Quite some time ago, maybe still current - try something like this:

Code:
proc sort data=oldTab; by tiliA tiliB; run;
data newTab;
  set oldTab (rename=(tiliB=oneB));
  by tiliA;
  length tiliB $50;  /* or whatever length you need */
  retain tiliB;
  if first.tiliA
    then tiliB = left(oneB);
	else tiliB = trim(tiliB) !! ' ' !! left(oneB);
  if last.tiliA then
   output;
run;
 
Code:
Proc Sort Data=NEW ;
  By TiliA ;
Run;

Data New ;
  Retain TiliB ;
  Set Old ;
  By TiliA ;
  If First.TiliA Then
  DO;
    TiliB = "" ;
    TiliB = TiliB!!" "!!TiliA ;
  END;
  IF Last.TiliA Then Output ;
RUN;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top