Monday, January 3, 2011

PROC TABULATE study notes

LIBNAME libref  'SAS-data-library';
PROC TABULATE DATA=SAS-data-set FORMAT=format.;
      CLASS variable(s);
      VAR variable(s);
      TABLE page-expression,row-expression,column-expression /
                <option(s)>;
      KEYLABEL keyword='text';
      LABEL variable1='label' variable2='label';
RUN;

1: In order to set up a table with PROC TABULATE, you need to identify the data you are analyzing, and then determine
which variables, if any, you need for classifying your data
which variables, if any, you need for analyzing your data
the type of table you need for representing your data.

2: The CLASS (categorical variables) statement and the VAR (analysis variables) statement specify the variables that you use in your table. Depending on the variables you specify, you can use one or both statements.


3: The TABLE statement specifies how PROC TABULATE uses variables and statistics to form the table.


4: Each variable that is listed in the TABLE statement must be specified in either a CLASS or VAR statement (but not in both).


5: Class variables
  • can be character or numeric.
  • classify data into groups or categories.
  • have only a few distinct values, in most cases. (PROC TABULATE prints each value of a class variable.)
analysis variables
  • must be numeric
  • are used for statistical analysis
  • often contain continuous values.


6: To request a statistic, you use the asterisk (*) operator to attach the statistic to the variable.
1: If you specify only class variables in your TABLE statement, then: the default statistic is N (frequency); the only statistics you can request are N and PCTN (percent of total frequency).

2: If you specify any analysis variables in your TABLE statement, then :the default statistic is SUM; you can request any statistic for the analysis variables.

3: In a single TABLE statement, you can specify statistics in any dimension, but they must all be in the same dimension. (that is, all statistics in the row dimension, or in the column dimension.)

7: You can change headings for statistics or for the special class variable ALL by using KEYLABEL. KEYLABEL keyword='text';

8
PROC TABULATE provides many other features that enable you to control the structure and appearance of your tables.
For example, you've seen several examples of concatenation, using the blank operator to display variables side by side or stacked (as shown below), or on adjacent pages.
     table height*mean weight*mean,sex all;


You can also produce hierarchical tables by using the asterisk operator to cross class variables with other variables.
     table sex,actlevel*age*max;


To group elements and control how expressions are evaluated, you can use the parentheses operator. For example, in the table below, ALL summarizes only categories for Sex, not for Type.
     table type*(sex all);


You can condense multiple pages into a single page.
     table type,fee,sum / condense;


You can specify the order of class variable values.
     proc tabulate data=clinic.admit order=formatted;


You can also control the spacing for row titles.
     table mean min max,height weight / rts=6; 


You can format selected table cells and their contents.
     table type*(sex all*f=5.);



You can also replace specific occurrences of a variable name or statistic name with a label.
     table type*(sex all='Both Sexes'*f=5.)
           all='Both Types'
;


No comments:

Post a Comment