Upcoming SlideShare
×

Visualizing Proc Transpose

736

Published on

A non-technical explanation of how SAS PROC TRANSPOSE works.

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
736
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Visualizing Proc Transpose"

1. 1. Visualizing PROC TRANSPOSE! An Introduction
2. 2. How do I know I need to Transpose? <ul><li>It’d sure be a lot easier if these observations were next to each other </li></ul><ul><ul><li>The UP Transpose </li></ul></ul><ul><li>It’d sure be a lot easier if these variables were observations one underneath each other </li></ul><ul><ul><li>The DOWN Transpose </li></ul></ul>
3. 3. Four Questions About Your Transpose <ul><li>What should stay the same? </li></ul><ul><li>What goes up? </li></ul><ul><li>What goes down? </li></ul><ul><li>What goes into the middle? </li></ul>BY ID VAR VAR
4. 4. On Base Percentage OBP = H+BB+HBP AB+BB+HBP+SF
5. 5. The Data – Calculate H+BB+HBP/AB+BB+HBP+SF 2 6 SF Nick Markakis Orioles 491 637 AB Nick Markakis Orioles 3 5 HBP Nick Markakis Orioles 43 61 BB Nick Markakis Orioles 143 191 H Nick Markakis Orioles 2 2 SF Kevin Millar Orioles 430 476 AB Kevin Millar Orioles 12 8 HBP Kevin Millar Orioles 59 76 BB Kevin Millar Orioles 117 121 H Kevin Millar Orioles Value2006 Value2007 Stat Player Team
6. 6. 1. What should stay the same? The BY Statement PROC TRANSPOSE DATA =Base_stats OUT =tran_stats; BY team player;
7. 7. 1. What should stay the same? Visualization Nick Markakis Orioles Nick Markakis Orioles Nick Markakis Orioles Nick Markakis Orioles Nick Markakis Orioles Kevin Millar Orioles Kevin Millar Orioles Kevin Millar Orioles Kevin Millar Orioles Kevin Millar Orioles Player Team 2 6 SF 491 637 AB 3 5 HBP 43 61 BB 143 191 H 2 2 SF 430 476 AB 12 8 HBP 59 76 BB 117 121 H Value2006 Value2007 Stat
8. 8. 2. What goes up? The ID Statement <ul><li>Up Movement creates VARIABLES from unique VALUES of the ID variable </li></ul>PROC TRANSPOSE DATA =Base_stats OUT =tran_stats; BY team player; ID stats;
9. 9. 2. What goes up? Visualization H H BB HBP AB SF HBP BB AB SF Nick Markakis Orioles Nick Markakis Orioles Nick Markakis Orioles Nick Markakis Orioles Nick Markakis Orioles Kevin Millar Orioles Kevin Millar Orioles Kevin Millar Orioles Kevin Millar Orioles Kevin Millar Orioles Player Team Stat
10. 10. 3. What goes down? The VAR Statement <ul><li>Individual variable NAMES are turned into VALUES of a new variable (_NAME_) </li></ul>PROC TRANSPOSE DATA =Base_stats OUT =tran_stats; BY team player; ID stats; VAR value2007 value2006; RUN ;
11. 11. 3. What goes down? Visualization Value2007 Value2006 Value2007 Value2006 HBP BB AB Nick Markakis Orioles Nick Markakis Orioles Kevin Millar Orioles Kevin Millar Orioles SF H _NAME_ Player Team 2 6 491 637 3 5 43 61 143 191 2 2 430 476 12 8 59 76 117 121
12. 12. 4. What goes into the middle? The VAR Statement <ul><li>The VALUES of value2006, value2007 are pushed into the newly created variables (H,BB,HBP,AB,SF) </li></ul>PROC TRANSPOSE DATA =Base_stats OUT =tran_stats; BY team player; ID stats; VAR value2007 value2006; RUN ;
13. 13. 4. What goes into the middle? Visualization Value2006 Value2006 121 76 8 476 2 191 61 5 637 6 117 59 12 430 2 143 43 3 491 2 Value2007 Value2007 HBP BB AB Nick Markakis Orioles Nick Markakis Orioles Kevin Millar Orioles Kevin Millar Orioles SF H _NAME_ Player Team
14. 14. Finished Product – Calculate H+BB+HBP/AB+BB+HBP+SF 2 6 2 2 SF 3 5 12 8 HBP 43 61 59 76 BB 491 637 430 476 AB 143 Value2006 Nick Markakis Orioles 191 Value2007 Nick Markakis Orioles 117 Value2006 Kevin Millar Orioles 121 Value2007 Kevin Millar Orioles H _NAME_ Player Team .351 .362 .374 .365 OBP