Amadeus cookies policy - you'll see this message only once.

Amadeus use cookies on this website. They help us to know a little bit about you and how you use our website, which improves the browsing experience and marketing - both for you and for others. They are stored locally on your computer or mobile device. To accept cookies, continue browsing as normal. Or, go to the privacy policy for more information.

Creating Professional Reports Using Proc TABULATE

Proc TABULATE is a very powerful procedure used for producing reports. It can generate detailed cross-tabulations of data, and has a number of inbuilt statistics to choose from.

The TABULATE procedure consists of a minimum of four statements:

  • PROC TABULATE data=SAS dataset;
  • Either CLASS variables; or VAR variables;
  • TABLE all variables listed on the CLASS and VAR statements
  • RUN;

The CLASS statement specifies the variables you want to classify the data with. These will form the rows and columns of the output table, and can be either character or numeric.

The VAR statement specifies the variables on which the analysis is performed, and must always be numeric.

The true power of using Proc TABULATE lies in the use of the TABLE statement – this is where you specify the structure of the table, including statistics you want to see and any formatting and labelling of columns.

The following example shows different operators in action, along with the MEAN statistic and using labels and options to control the appearance of the table. We are aiming to produce a table showing the average price of cars by the type of car and the number of cylinders they have. We want totals by both type and number of cylinders and we want the output formatted in GBP.

proc tabulate data=sashelp.cars format=nlmnlgbp16.2;
  var MSRP;
  class type cylinders;
  table type='Type of Car'
        all='Total',
        cylinders='Number of Cylinders' *
        MSRP=' ' * mean=' '
        all='Total' * MSRP='' * mean=''
        /box='Average Price' misstext='NO DATA';
run;

This produces the following table:

Average Price        

Number of   Cylinders

Total   

 

8

10

12

 

Type of Car

 

 

 

 

Hybrid

NO   DATA

NO DATA

NO DATA

£19,920.00

SUV

£48,043.64

£41,475.00

NO DATA

£4,790.25

Sedan

£51,418.68

NO DATA

£101,710.00

£29,773.62

Sports

£67,625.00

£81,795.00

£126,670.00

£54,533.32

Truck

£34,294.33

NO DATA

NO DATA

£24,941.38

Wagon

£46,597.50

NO DATA

NO DATA

£28,840.53

Total

£51,179.99

£61,635.00

£110,030.00

£32,804.55

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Note the use of the keyword ALL, which produces totals for both make and cylinders. Also note the options BOX, which specifies the text in the top left of the table, providing a heading and MISSTEXT which prints the value specified where there is missing data.

The TABLULATE procedure is extremely powerful and only the basics have been touched on here. Please refer to the Native SAS Help Documentation or online to see the benefits of using Proc TABULATE to produce your reports.