Title: Anyone Can Learn PROC TABULATE
1Anyone Can Learn PROC TABULATE
- Lauren HaworthGenentech, Inc., South San
Francisco
2Introduction
- No matter how you organize and analyze your data,
chances are youll end up producing a report in
the form of a table - This is why every SAS user needs to know how to
use PROC TABULATE
3Unfortunately, TABULATE has gotten a bad rap as
being a difficult procedure to learn.
- This paper will prove that if you take things
step by step, anyone can learn PROC TABULATE.
4This paper will cover
- basic one-dimensional tables
- two-dimensional tables
- tables with totals
- three-dimensional tables
- cleaning up your tables
- creating HTML output
5The Simplest Possible Table
6The Simplest Possible Table
- PROC TABULATE DATATEMP TABLE RENTRUN
7The Simplest Possible Table
- PROC TABULATE DATATEMP VAR RENT TABLE
RENTRUN
8Output
9Adding a Statistic
- PROC TABULATE DATATEMP VAR RENT TABLE
RENTRUN
10Adding a Statistic
- PROC TABULATE DATATEMP VAR RENT TABLE
RENTMEANRUN
11Output
12Adding Another Statistic
- PROC TABULATE DATATEMP VAR RENT TABLE
RENTMEANRUN
13Adding Another Statistic
- PROC TABULATE DATATEMP VAR RENT TABLE
RENTNRUN
14Adding Another Statistic
- PROC TABULATE DATATEMP VAR RENT TABLE
RENTN RENTMEANRUN
15Output
-
- Rent Rent
-
- N Mean
-
- 198.00 1335.93
16Using Parentheses
- PROC TABULATE DATATEMP VAR RENT TABLE
RENTN RENTMEANRUN
17Using Parentheses
- PROC TABULATE DATATEMP VAR RENT TABLE
RENT(N MEAN)RUN
18Output
-
- Rent
-
- N Mean
-
- 198.00 1335.93
19Adding a Classification Variable
- PROC TABULATE DATATEMP VAR RENT TABLE
RENTMEANRUN
20Adding a Classification Variable
- PROC TABULATE DATATEMP CLASS CITY VAR
RENT TABLE RENTMEANRUN
21Adding a Classification Variable
- PROC TABULATE DATATEMP CLASS CITY VAR
RENT TABLE RENTMEANCITYRUN
22Output
-
- Rent
-
- Mean
-
- City
-
- San
- Portland Francisco Long Beach
-
- 931.44 2282.22 1116.00
23Two-dimensional tables
- PROC TABULATE DATATEMP VAR RENT TABLE
RENT(N MEAN)RUN
24Output
-
- Rent
-
- N Mean
-
- 198.00 1335.93
25Adding the second dimension
- PROC TABULATE DATATEMP VAR RENT TABLE
RENT(N MEAN)RUN
26Adding the second dimension
- PROC TABULATE DATATEMP CLASS BEDROOMS
VAR RENT TABLE RENT(N MEAN)RUN
27Adding the second dimension
- PROC TABULATE DATATEMP CLASS BEDROOMS
VAR RENT TABLE BEDROOMS, RENT(N
MEAN)RUN
28Output
-
- Rent
-
- N Mean
-
- Bedrooms
-
- 1 Bedroom 92.00 1180.35
-
- 2 Bedrooms 106.00 1470.96
29Adding class variables on both dimensions
- PROC TABULATE DATATEMP CLASS BEDROOMS
VAR RENT TABLE BEDROOMS, RENTMEANRUN
30Adding class variables on both dimensions
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS,
RENTMEANRUN
31Adding class variables on both dimensions
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS,
RENTCITYMEANRUN
32Output
- Rent
-
- City
-
- San
- Portland Francisco Long Beach
-
- Mean Mean Mean
- Bedrooms
-
- 1 Bedroom 800.08 2063.83
955.23
- 2 Bedrooms 1050.29 2483.81
1242.92
33Adding Another Classification Variable
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS,
RENTCITYMEANRUN
34Adding Another Classification Variable
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
PARKING VAR RENT TABLE BEDROOMS,
RENTCITYMEANRUN
35Adding Another Classification Variable
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
PARKING VAR RENT TABLE BEDROOMS PARKING,
RENTCITYMEANRUN
36Output
- Rent
-
- City
-
- San
- Portland Francisco Long Beach
-
- Mean Mean Mean
- Bedrooms
-
- 1 Bedroom 800.08 2063.83
955.23
- 2 Bedrooms 1050.29 2483.81
1242.92
- Parking
-
- No 781.75 1785.30
1060.54
37Nesting the Classification Variable
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
PARKING VAR RENT TABLE BEDROOMS PARKING,
RENTCITYMEANRUN
38Nesting the Classification Variable
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
PARKING VAR RENT TABLE BEDROOMSPARKING,
RENTCITYMEANRUN
39Output
- Rent
-
- City
-
- San
- Portland Francisco
Long Beach -
- Mean Mean
Mean
- Bedrooms Parking
-
- 1 Bedroom No 707.00
1586.10 896.00 -
- Yes 843.04
2405.07 984.85
- 2 BedroomsNo 856.50
1984.50 1151.94 -
- Yes 1127.80
2795.88 1324.80
40Adding Totals to the Rows
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
TABLE BEDROOMS, CITYNRUN
41Output
- City
-
- San
- Portland Francisco Long Beach
-
- N N N
- Bedrooms
-
- 1 Bedroom 38.00 24.00
30.00
- 2 Bedrooms 42.00 26.00
38.00
42Adding Totals to the Rows
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
TABLE BEDROOMS, CITYNRUN
43Adding Totals to the Rows
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
TABLE BEDROOMS, CITYN ALLRUN
44Adding Totals to the Rows
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
TABLE BEDROOMS, CITYN ALLNRUN
45Adding Totals to the Rows
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
TABLE BEDROOMS, (CITY ALL)NRUN
46Output
- City
-
- San
- Portland Francisco Long Beach
All -
- N N N
N
- Bedrooms
-
- 1 Bedroom 38.00 24.00
30.00 92.00
- 2 Bedrooms 42.00 26.00
38.00 106.00
47Adding Totals to the Columns
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
TABLE BEDROOMS, CITYNRUN
48Adding Totals to the Columns
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
TABLE BEDROOMS ALL, CITYNRUN
49Output
- City
-
- San
- Portland Francisco Long Beach
-
- N N N
- Bedrooms
-
- 1 Bedroom 38.00 24.00
30.00
- 2 Bedrooms 42.00 26.00
38.00
- All 80.00 50.00
68.00
50Three-Dimensional Tables
51Three-Dimensional Tables
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT - TABLE BEDROOMS, (CITY ALL)RENTMEANRUN
52Output
- City
-
- San
- Portland Francisco Long Beach
All -
- Rent Rent Rent
Rent -
- Mean Mean Mean
Mean
- Bedrooms
-
- 1 Bedroom 800.08 2063.83
955.23 1180.35
- 2 Bedrooms 1050.29 2483.81
1242.92 1470.96
53Three-Dimensional Tables
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT - TABLE BEDROOMS, (CITY ALL)RENTMEANRUN
54Three-Dimensional Tables
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
PARKING VAR RENT - TABLE BEDROOMS, (CITY ALL)RENTMEANRUN
55Three-Dimensional Tables
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
PARKING VAR RENT - TABLE PARKING, BEDROOMS, (CITY
ALL)RENTMEANRUN
56Output
- Parking No
- City
-
- San
- Portland Francisco Long Beach
All -
- Rent Rent Rent
Rent -
- Mean Mean Mean
Mean
- Bedrooms
-
- 1 Bedroom 707.00 1586.10
896.00 1040.78
- 2 Bedrooms 856.50 1984.50
1151.94 1271.45
57Output
- Parking Yes
- City
-
- San
- Portland Francisco Long Beach
All -
- Rent Rent Rent
Rent -
- Mean Mean Mean
Mean
- Bedrooms
-
- 1 Bedroom 843.04 2405.07
984.85 1254.78
- 2 Bedrooms 1127.80 2795.88
1324.80 1591.88
58Making the table pretty
59Making the table pretty
- City
-
- San
- Portland Francisco Long Beach
All -
- Rent Rent Rent
Rent -
- Mean Mean Mean
Mean
- Bedrooms
-
- 1 Bedroom 800.08 2063.83
955.23 1180.35
- 2 Bedrooms 1050.29 2483.81
1242.92 1470.96
60Clarifying a Label
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS, (CITY ALL) - RENTMEANRUN
61Clarifying a Label
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS, (CITY
ALLOverall) - RENTMEANRUN
62Output
- City
-
- San
- Portland Francisco Long Beach
Overall -
- Rent Rent Rent
Rent -
- Mean Mean Mean
Mean
- Bedrooms
-
- 1 Bedroom 800.08 2063.83
955.23 1180.35
- 2 Bedrooms 1050.29 2483.81
1242.92 1470.96
63Removing an Extra Label
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS, (CITY
ALLOverall) - RENTMEANRUN
64Removing an Extra Label
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS, (CITY
ALLOverall) - RENTMEANRUN
65Output
- San
- Portland Francisco Long Beach
Overall -
- Rent Rent Rent
Rent -
- Mean Mean Mean
Mean
- Bedrooms
-
- 1 Bedroom 800.08 2063.83
955.23 1180.35
- 2 Bedrooms 1050.29 2483.81
1242.92 1470.96
66Removing More Labels
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS, (CITY
ALLOverall) - RENTMEANRUN
67Removing More Labels
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS , (CITY
ALLOverall) - RENT MEAN RUN
68Output
- San
- Portland Francisco Long Beach
Overall
- 1 Bedroom 800.08 2063.83
955.23 1180.35
- 2 Bedrooms 1050.29 2483.81
1242.92 1470.96
69Adding a Combined Label
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS , (CITY
ALLOverall) - RENT MEAN RUN
70Adding a Combined Label
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS , (CITY
ALLOverall) - RENT MEAN
- / BOXAverage RentRUN
71Output
- Average San
- Rent Portland Francisco Long Beach
Overall
- 1 Bedroom 800.08 2063.83
955.23 1180.35
- 2 Bedrooms 1050.29 2483.81
1242.92 1470.96
72Formatting the Data
- PROC TABULATE DATATEMP CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS , (CITY
ALLOverall) - RENT MEAN
- /BOXAverage RentRUN
73Formatting the Data
- PROC TABULATE DATATEMP
- FORMATDOLLAR12. CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS , (CITY
ALLOverall) - RENT MEAN
- /BOXAverage RentRUN
74Output
- Average San
- Rent Portland Francisco Long Beach
Overall
- 1 Bedroom 800 2,064
955 1,180
- 2 Bedrooms 1,050 2,484
1,243 1,471
75Before
- City
-
- San
- Portland Francisco Long Beach
All -
- Rent Rent Rent
Rent -
- Mean Mean Mean
Mean
- Bedrooms
-
- 1 Bedroom 800.08 2063.83
955.23 1180.35
- 2 Bedrooms 1050.29 2483.81
1242.92 1470.96
76After
- Average San
- Rent Portland Francisco Long Beach
Overall
- 1 Bedroom 800 2,064
955 1,180
- 2 Bedrooms 1,050 2,484
1,243 1,471
77Creating HTML Output
78Creating HTML Output V8
- ODS HTML BODYSAMPLE.HTMLPROC TABULATE
DATATEMP - FORMATDOLLAR12. CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS , (CITY
ALLOverall) - RENT MEAN
- /BOXAverage RentRUNODS HTML CLOSE
79Output
80Changing the Style
- ODS HTML BODYSAMPLE.HTML STYLEBARRETTSBLUE
PROC TABULATE DATATEMP - FORMATDOLLAR12. CLASS BEDROOMS CITY
VAR RENT TABLE BEDROOMS , (CITY
ALLOverall) - RENT MEAN
- /BOXAverage RentRUNODS HTML CLOSE
81Output - BARRETTSBLUE
82Output - BRICK
83Output - BROWN
84Output D3D
85Output - MINIMAL
86Output - STATDOC
87Output - THEME
88Conclusions
- At this point, you should be able to produce a
simple table with totals, - clean it up a bit,
- and create HTML output
- To learn more
- review the TABULATE manual
- read other SUGI papers
- (Warning here comes the commercial)
89Conclusions
- At this point, you should be able to
- produce a simple table with totals,
- clean it up a bit,
- and create HTML output
- To learn more
- review the TABULATE manual
- read other SUGI papers
- read my book!
90Thanks for coming!