When creating summary reports with SAS© (whether via SAS© Data Integration Studio or in Base SAS© code), the PROC TABULATE procedure is a powerful tool. However, it is common to encounter a blocking error message when submitting the job, which looks like this:
The first instinct is often to think of a software bug or a missing hotfix. However, in the vast majority of cases, it is a fundamental syntax problem related to the logic of PROC TABULATE.
The Golden Rule: CLASS vs VAR
To understand the error, you need to understand how SAS© processes data in this procedure. Unlike other procedures, PROC TABULATE requires that every variable mentioned in the TABLE statement be previously defined.
SAS© needs to know how to process the variable:
Is it a classification variable that will create rows or columns?
Is it a numeric variable on which statistics (sums, averages) will be calculated?
If a variable appears in the TABLE statement without being declared, SAS© does not know its usage "type", hence the "unknown" error.
To fix this problem, you must define the usage of your variables using the CLASS and VAR statements.
The CLASS statement: Use it for categorical variables (e.g., Department, Course Name, Section). These are the variables that create the "buckets" or groupings.
The VAR statement: Use it for analysis variables (e.g., Total Cost, Salary). These are the variables on which calculations are performed.
Concrete Example
Let's imagine you want to create a table crossing the course name with the department, section, and total cost.
The incorrect code (which generates the error):
The corrected code:
Here, we define course_name, department, and section as classification variables, and tot_cost as the analysis variable.
Before contacting technical support or looking for a software patch, always check your syntax. If you use a variable in your table structure (TABLE), make sure it is listed in either the CLASS statement or the VAR statement.