SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating Tabular Reports
Specifying Statistics


Your final task before writing your own PROC TABULATE step is to specify the statistics needed. To request a statistic, you use an operator, the asterisk (*), to attach the statistic to the variable.

In the TABLE statements below, the statistic MEAN is specified for the variable Fee. Notice that you don't specify statistics in the CLASS or VAR statements. Notice also how changing the order of the variable and statistic affects the table produced.

     proc tabulate data=clinic.admit;
        var fee;
        table fee*mean;
     run;

Fee
Mean
127.95


     proc tabulate data=clinic.admit;
        var fee;
        table mean*fee;
     run;

Mean
Fee
127.95


Rules for Specifying Statistics

Three rules apply to specifying statistics.

  1. If you specify only class variables in your TABLE statement,
    • the default statistic is N (frequency)
    • the only statistics you can request are N and PCTN (percent of total frequency).

    The TABLE statement in the PROC TABULATE step below specifies only class variables, so it can request only N and PCTN.

         proc tabulate data=clinic.admit;
            class sex actlevel;
            table sex*pctn actlevel*n;
         run;
    
  2. If you specify any analysis variables in your TABLE statement,
    • the default statistic is SUM
    • you can request any statistic to be computed on the analysis variables.

    The TABLE statement in the PROC TABULATE step below contains two analysis variables, so it can request any statistic.

         proc tabulate data=clinic.admit;
            class actlevel;
            var height weight;
            table height*mean weight*max,actlevel;
         run;
    
  3. In a TABLE statement, you can specify statistics in any dimension, but they must all be in the same dimension.
     proc tabulate data=clinic.admit;
        class sex actlevel;
        var height weight;
        table height*mean weight*max,actlevel;
        table sex*pctn actlevel*n;
     run;

In the first TABLE statement above, the statistics are in the row dimension. In the second TABLE statement, the statistics are in the column dimension.


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement