The SAS Output Delivery System and reporting techniques

restricting the statistics

Posts: 0

restricting the statistics

I dont want to use any statistic to numeric variable which I am using in the var statement of proc tabulate, is it possible?
proc tabulate data=sample;
class x y z;
var w;
table x, y*(z,w);
here I am getting sum of the values for the variable w, but I dont the sum. I just want to display the value of the variable W as it is.
please help me
Posts: 8,743

Re: restricting the statistics

Look at and run the program below. Proc TABULATE is a summary procedure. If you have only one observation something uniquely identified by X, Y, Z values, then you should get the one row from TABULATE. However, Proc TABULATE's main purpose in life is to be a SUMMARY procedure and produce SUMMARY tables. So the default statistic associated with any numeric variable is the SUM statistic.

Depending on what you want to do, you may prefer output from PROC PRINT or PROC REPORT.

I'm not sure how you're getting numbers from TABULATE, when I run your program, I get the following error message:
504 table x, y*(z,w);
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, ), *,
-, :, <, =, [, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_, {.
ERROR 200-322: The symbol is not recognized and will be ignored.
505 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


Both Proc PRINT and Proc REPORT will essentially provide you with a "detail" report, where every report row represents one observation in the data. For example, SASHELP.CLASS has 19 observations, one for each of 19 students. In my program, I create a data set called SAMPLE from SASHELP.CLASS and I create 21 observations -- an extra one for Alfred and an extra one for Janet. You can see, if you review the program output, that PROC PRINT and PROC REPORT show 2 rows for Alfred and 2 rows for Janet. But, PROC TABULATE creates just one report row for each of these students (and summarizes their values for W).


data sample;
set sashelp.class;

x = sex;
z = name;
if height gt 59 then y = 'XXX';
else y = 'YYY';
w = age;

** create some extra obs to see diff between TAB and REPORT;
if name = 'Alfred' then output;
else if name = 'Janet' then output;

proc sort data=sample out=sample;
by x y z w;

ods html file='c:\temp\sample.html' style=sasweb;
proc print data=sample;
title 'Look at DATA';
title2 'Alfred and Janet each have 2 rows';
var x y z w;

proc tabulate data=sample f=comma5.;
title 'Proc TABULATE';
title2 'With Tabulate, Alfred will have a value of 28 for W and Janet will have a value of 30';
class x y z;
var w;
table x, y*z ,w;
keylabel sum = ' ';

proc report data=sample nowd;
title 'Proc REPORT';
title2 'With Proc REPORT, Alfred will have 2 rows of detail data and Janet will have 2 rows of detail data';
column x y z w;
define x / order;
define y / order;
define z / order;
define w / display;
break after x / page;

proc tabulate data=sample;
title 'Original Program - gets error message';
class x y z;
var w;
table x, y*(z,w);

ods html close;
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation