Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.OASUS.ca “Come out of the desert of ignorance to the OASUS of knowledge” Proc du Jour: PROC TRANSPOSE Tom Kari Tom Kari Consulting OASUS, November.

Similar presentations


Presentation on theme: "Www.OASUS.ca “Come out of the desert of ignorance to the OASUS of knowledge” Proc du Jour: PROC TRANSPOSE Tom Kari Tom Kari Consulting OASUS, November."— Presentation transcript:

1 www.OASUS.ca “Come out of the desert of ignorance to the OASUS of knowledge” Proc du Jour: PROC TRANSPOSE Tom Kari Tom Kari Consulting OASUS, November 20

2 www.OASUS.ca Simplest case data SimpleTransposeIn; input A B C; cards; 1 2 3 10 20 30 100 200 300 run; proc transpose data=SimpleTransposeIn out=SimpleTransposeOut; run; November 20, 2014Tom Kari, Tom Kari Consulting2

3 www.OASUS.ca ID Variable data FinanceData; length Region $9; input Region NetSales; cards; EMNA 3253 EME 749 EMIO 430 EMSA 403 Corporate 4.8 run; proc transpose data=FinanceData out=Transposed; ID Region; run; November 20, 2014Tom Kari, Tom Kari Consulting3 Specifies one or more variables in the input data set whose formatted values name the transposed variables in the output data set. Can use with prefix, suffix, delimiter options. IDLabel statement provides a variable that contains the labels for the new variables.

4 www.OASUS.ca BY Variable data QuarterlyData; length Region $9; input Region Quarter NetSales; cards; EMNA 1 3253 EME 1 749... Corporate 4 6.3 run; proc sort data=QuarterlyData; by Region; proc transpose data=QuarterlyData out=TransposedQuarterly prefix=Q; by Region; ID Quarter; var NetSales; run; November 20, 2014Tom Kari, Tom Kari Consulting4 Excludes one or more variables from being transposed Data must be sorted by the BY variable(s)

5 www.OASUS.ca BY Variable (cont’d) November 20, 2014Tom Kari, Tom Kari Consulting5

6 www.OASUS.ca Additional comments November 20, 2014Tom Kari, Tom Kari Consulting6 Like PROC SORT, this procedure is intended purely for data processing PROC TRANSPOSE has no provisions for ODS PROC TRANSPOSE will frequently convert numeric variables to character Enterprise Guide provides a good Transpose task

7 www.OASUS.ca Use case 1: “Datapoint” files November 20, 2014Tom Kari, Tom Kari Consulting7 PersonNameGenderAgeHeight 1AlfredM1469 2AliceF1356.5 3BarbaraF1365.3 4CarolF1462.8 5HenryM1463.5 6JamesM1257.3 7JaneF1259.8 8JanetF1562.5 9JeffreyM1362.5 10JohnM1259 11JoyceF1151.3 12JudyF1464.3 13LouiseF1256.3 14MaryF1566.5 15PhilipM1672 16RobertM1264.8 17RonaldM1567 18ThomasM1157.5 19WilliamM1566.5 PersonVariableValue 1NameAlfred 1GenderM 1Age14 1Height69 2NameAlice 2GenderF 2Age13 2Height56.5 3NameBarbara 3GenderF 3Age13 3Height65.3 … 76 rows

8 www.OASUS.ca Convert from relational to “Datapoint” files November 20, 2014Tom Kari, Tom Kari Consulting8

9 www.OASUS.ca Convert from “Datapoint” to relational November 20, 2014Tom Kari, Tom Kari Consulting9

10 www.OASUS.ca Use case 2: Edit Spreadsheets November 20, 2014Tom Kari, Tom Kari Consulting10 Spreadsheets are a terrible way to transfer important data from one organization to another: They are prone to ad-hoc changes; There’s always the risk of transferring the wrong month, version, location; “Glitches” frequently pop up. Yet everybody does it!

11 www.OASUS.ca What could go wrong? November 20, 2014Tom Kari, Tom Kari Consulting11

12 www.OASUS.ca What could go wrong? November 20, 2014Tom Kari, Tom Kari Consulting12

13 www.OASUS.ca What could go wrong? November 20, 2014Tom Kari, Tom Kari Consulting13

14 www.OASUS.ca What could go wrong? November 20, 2014Tom Kari, Tom Kari Consulting14

15 www.OASUS.ca Spaghetti code! November 20, 2014Tom Kari, Tom Kari Consulting15

16 www.OASUS.ca A different approach November 20, 2014Tom Kari, Tom Kari Consulting16 Transpose one of your spreadsheets (turn rows and columns into rows identified by cell id, e.g. B17) Separate your cells into “static” (the contents should always be the same), and “fixed” (contains data that we want to capture). Set this table up as a reference table. For your production processing: –Pull your spreadsheet into SAS (PROC IMPORT); –Transpose the cells same way, into rows with a cell id; –Match to the reference table by cell id: If static and values don’t match, we have a problem. If a reference cell is empty, and a test cell isn’t, or vice versa, do we have a problem? –Pull out your “fixed” cell ids (we know what they are from the reference table), and transpose them. You’ll get one record with your data!

17 www.OASUS.ca November 20, 2014Tom Kari, Tom Kari Consulting17


Download ppt "Www.OASUS.ca “Come out of the desert of ignorance to the OASUS of knowledge” Proc du Jour: PROC TRANSPOSE Tom Kari Tom Kari Consulting OASUS, November."

Similar presentations


Ads by Google