BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
podarum
Quartz | Level 8

Hi,  I have a list of accounts and their customer Ids, some accounts can have more than 1 customer and different customer types.  I would like to transpose by type of customer.  Here's what I mean:

 

HAVE

Acct      Type_A     Type_B     Type_C

001          123            234      

001          123            356 

002          567            124           345

002          567            124           678

 

WANT

Acct     Type_A       Type_B1       Type_B2       Type_C1       Type_C2

001         123               234                  356              

002         567               124                                          345              678

 

This logic applied to a list of 1 million accouts.

 

thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Hi @podarum  Assuming I understand the req.

 

data have;
infile cards truncover;
input Acct   $   Type_A     Type_B     Type_C;
cards;
001          123            234      
001          123            356 
002          567            124           345
002          567            124           678
;
data temp;
 set have;
 by acct;
 if first.acct then grp=0;
 grp+1;
 array t type_:;
 do over t;
  vn=vname(t);
  v=t;
  output;
 end;
 drop type_:;
run;

proc sort data=temp out=temp2 nodupkey;
by acct vn v;
run;

proc transpose data=temp2 out=want(drop=_:);
by acct;
id vn grp;
var v;
run;

 

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Hi @podarum  Assuming I understand the req.

 

data have;
infile cards truncover;
input Acct   $   Type_A     Type_B     Type_C;
cards;
001          123            234      
001          123            356 
002          567            124           345
002          567            124           678
;
data temp;
 set have;
 by acct;
 if first.acct then grp=0;
 grp+1;
 array t type_:;
 do over t;
  vn=vname(t);
  v=t;
  output;
 end;
 drop type_:;
run;

proc sort data=temp out=temp2 nodupkey;
by acct vn v;
run;

proc transpose data=temp2 out=want(drop=_:);
by acct;
id vn grp;
var v;
run;

 

podarum
Quartz | Level 8

You Rock.. Thank You !!!