DATA Step, Macro, Functions and more

automatically name transposed columns

Accepted Solution Solved
Reply
Super Contributor
Posts: 441
Accepted Solution

automatically name transposed columns

Hi,

 

suppose that I have the following table:

 

date  stock price
21-Jan-10 A 1
22-Jan-10 A 3
21-Jan-10 B 10
22-Jan-10 B 15

 

when I do the following code:

 

proc sort data=have;
by date;
run;
proc transpose data=have out=want ;
by date;
run;

I ge the result:

date _NAME_ _LABEL_ COL1 COL2
21/01/2010 price price 1 10
22/01/2010 price price 3 15

 

But the names of the stocks (A and B) appear as COL1 and COL2 - is it possible to have the real names of the stocks?

 

Thank you!


Accepted Solutions
Solution
‎11-06-2016 10:59 PM
Super User
Posts: 5,518

Re: automatically name transposed columns

Try adding to your current PROC TRANSPOSE:

 

id stock;

 

That's probably exactly what you are asking for.

View solution in original post


All Replies
Solution
‎11-06-2016 10:59 PM
Super User
Posts: 5,518

Re: automatically name transposed columns

Try adding to your current PROC TRANSPOSE:

 

id stock;

 

That's probably exactly what you are asking for.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 148 views
  • 0 likes
  • 2 in conversation