SAS Base Programming study materials
SAS Base Programming study resources

SAS Base Programming: Generate Reports and Output

SAS Base Programming · Work through your exam, one topic at a time.

All guide sections

Generate Reports and Output

The reporting procedures

PROC PRINT lists data: VAR selects and orders columns, ID replaces the observation number, BY produces sorted sections, SUM adds totals, NOOBS and LABEL adjust appearance. PROC FREQ counts: one-way and n-way TABLES, LIST for multi-way output, NOCUM/NOPERCENT/NOFREQ suppress statistics, OUT= saves counts. PROC MEANS summarizes numeric variables with default statistics N, MIN, MAX, MEAN, and STD; use CLASS for unsorted grouping, BY for sorted sections, MAXDEC for decimals, and OUTPUT= with statistic=name syntax to create a table. PROC REPORT defines column order in the COLUMN statement and each column's role in DEFINE (DISPLAY, ORDER, GROUP, ACROSS, ANALYSIS), with COMPUTE blocks, BREAK, and RBREAK for custom summaries. PROC TABULATE builds cross-tabulations from comma-separated dimensions.

Traps

BY requires sorted input and stops with an error if the data are unsorted; CLASS does not sort but produces one table of groups. Omitting VAR in PROC MEANS summarizes every numeric variable, which pollutes the output. A TITLE statement stays in effect for the rest of the session until it is changed or cleared with TITLE; - a missing semicolon there creates confusing errors. ODS destinations (HTML, PDF, RTF, LISTING) are opened with ODS ... FILE= and closed with ODS ... CLOSE; ODS SELECT/EXCLUDE limits which output objects appear, and ODS OUTPUT saves an object as a data set.

Rule of thumb

BY = sorted subsets (one section per value); CLASS = unsorted groups (one table, grouped rows).

proc means data=work.sales n mean maxdec=2;
  class region;
  var amount;
run;