Desktop productivity for business analysts and programmers

Transpose Split Stack

Reply
Contributor
Posts: 41

Transpose Split Stack

[ Edited ]

Example data

Supervisor Empl Eval_Date Score

Johnson    Smith 1/1/15       25

Johnson    Miller 1/1/15       26

Hanson     Poole 1/2/15       25

 

Desired Ouput:

Name        Eval_Date  Score

Johnson    

Smith        1/1/15          25

Miller         1/1/15         26

Hanson

Poole        1/2/15          25

 

I'm trying to accomplish this without a proc but can if I need to.

Respected Advisor
Posts: 4,992

Re: Transpose Split Stack

[ Edited ]

I'm not certain that this is a good idea, but here's one way:

 

data want;

set have;

by Supervisor notsorted;

if first.Supervisor then do;

   Name = Supervisor;

   output;

end;

Name = Empl;

D = Eval_Date;

S = Score;

output;

keep Name D S;

rename D = Eval_Date;

rename S = Score;

run;

 

Good luck.

Trusted Advisor
Posts: 1,203

Re: Transpose Split Stack

Another way using sql

 

data have;
input Supervisor $ Empl $ Eval_Date anydtdte. Score;
format Eval_Date mmddyy8.;
datalines;
Johnson    Smith  1/1/15       25
Johnson    Miller 1/1/15       26
Hanson     Poole  1/2/15       25
;

 

proc sql;
select distinct supervisor as supervisor from have
union
select * from have
order by supervisor, empl;
quit;

Ask a Question
Discussion stats
  • 2 replies
  • 286 views
  • 1 like
  • 3 in conversation