-1
ODS EXCEL FILE="/mypoath/myfile.xlsx" options(
    frozen_headers="3"
    sheet_name="#byval1");
 PROC TABULATE data=out;
  BY byVariable; 
  CLASS varA varB;
  TABLES varA, varB;
 RUN;
ODS EXCEL CLOSE;

The code above creates an excel-file with different sheets. There is one sheet for each value of the variable byVariable. Is there a way to create an additional sheet "ALL" which contains the results for all values of the byVariable together? I mean something like "ALL" (used in the TABLES-section). I tried BY ALL byVar already (which doesn't work). Thanks for help!

D. Studer
  • 1,711
  • 1
  • 16
  • 35

2 Answers2

1

The simple answer is NO. If you want all of the data then don't use the BY statement.

ODS EXCEL FILE="/mypoath/myfile.xlsx" options(frozen_headers="3");
ODS EXCEL options(sheet_name="ALL");
PROC TABULATE data=out;
  CLASS varA varB;
  TABLES varA, varB;
RUN;
ODS EXCEL options(sheet_name="#byval1");
PROC TABULATE data=out;
  BY byVariable; 
  CLASS varA varB;
  TABLES varA, varB;
RUN;
ODS EXCEL CLOSE;
Tom
  • 47,574
  • 2
  • 16
  • 29
1

There is no such option.

You can:

  • rerun the report without BY, or
  • stack the data on itself modifying the by variable to be ALL -- such that it is higher than all existant by values.
data stacked / view=stacked;
  set 
    have
    have (in=stackflag)
  ;

  if stackflag then do;
    byvar = 'A0'x || 'ALL';        * A0 forces value to be 'after' other original byVar values;
  end
run;

proc tabulate data=stacked;
  by byvar; 
  …

Note: 'A0'x is a hard space ASCII character

Richard
  • 25,390
  • 3
  • 25
  • 38