Skip to main content
v2026.11,986 entries · CC-BY 4.0

PROC PRINT in SAS: Syntax, Options and Examples

PROC PRINT in SAS lists data set observations. Learn the syntax, key options (DATA=, VAR, BY, NOOBS, LABEL), a worked example and fixes.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

PROC PRINT in SAS prints the observations of a SAS data set, so you can see the actual values your analysis will use. Name the data set with DATA=, list the columns you want in a VAR statement, and add options such as NOOBS (no observation numbers) or LABEL (variable labels as column headings). SAS documentation summarises the procedure as “Print observations in a data set.” This guide covers the syntax, a worked sectioned report with BY, how to read the result and what to check when it does not look right.

What PROC PRINT is used for in research

PROC PRINT shows data values; it does not summarise them. In a research workflow that makes it the quickest way to check that an import, a merge or a recode produced what you intended before any model is fitted. It is also the way to list a handful of records, such as the rows behind an outlier flagged elsewhere, or to produce a simple listing for a data-management query.

It answers a different question from its neighbours. PROC CONTENTS describes a data set’s structure (variable names, types, lengths), PROC PRINT shows the values, and PROC UNIVARIATE summarises their distribution. A common sequence is to check structure, print a small number of rows, and only then summarise. When two versions of a data set need to be reconciled, PROC COMPARE is the better tool than reading two listings by eye. Keeping the printed check in the program, rather than looking at a table window, also leaves a record of what was inspected, which supports computational reproducibility.

How to install or access PROC PRINT

PROC PRINT is a procedure in Base SAS, so it is available wherever you can run SAS code; there is nothing separate to install. Researchers normally reach SAS through an institutional installation or licence, so follow your institution’s approved route. For learning, SAS provides SAS OnDemand for Academics, which its support page describes as “an online delivery model for teaching and learning statistical analysis, data mining and forecasting” and which is used through SAS Studio. The page lists separate routes for independent learners (a registration application), students (an enrolment link from the instructor) and instructors (who register, create a course and invite students). Practise on the invented data in this guide rather than on institutional research files. The SAS coding guide covers how a first program is structured.

How to use PROC PRINT step by step

Syntax in brief

The procedure’s documented syntax (SAS 9.4) is shown below; the documentation marks optional items with angle brackets, shown here as square brackets.

PROC PRINT [option(s)];
  BY [DESCENDING] variable-1 [...variable-n] [NOTSORTED];
  PAGEBY BY-variable;
  SUMBY BY-variable;
  ID variable(s) [option];
  SUM variable(s) [option];
  VAR variable(s) [option];

Only the PROC PRINT statement is needed. Printing a whole data set is one line plus RUN;: proc print data=work.visits; run;. The options below change what is printed and how.

A worked example: a sectioned listing

This illustrative composite uses invented participants and scores; it is not research data. The goal is a listing of scores by study site, without observation numbers, with readable column headings.

  1. Create the example data.
    data visits;
      input participant $ site $ visit score;
      datalines;
    P01 North 1 14
    P02 South 1 11
    P03 North 2 17
    P04 South 2 12
    P05 North 1 15
    ;
    run;
  2. Sort by the BY variable. The documentation’s own sectioned-report example runs PROC SORT on the BY variables first, so do the same:
    proc sort data=visits;
      by site visit;
    run;
  3. Print with BY, VAR, NOOBS and LABEL.
    proc print data=visits noobs label;
      by site;
      var participant visit score;
      label participant='Participant ID' score='Total score';
      title 'Scores by study site (invented data)';
    run;
  4. Check the result against the data. You should see one section per value of site, the column headings Participant ID, visit and Total score, and no observation-number column.

The documentation’s Example 3 combines the same ideas with PAGEBY and N=: proc print data=exprev n='Number of observations for the month: ' noobs label; var quantity cost price; by sale_type order_date; pageby order_date;, preceded by options nodate pageno=1 obs=10;. In that example each Sale_Type gets its own section, the page changes when Order_Date changes, and each BY group shows its count after the N= text. The OBS=10 there is a system option that limits the run to ten observations, which is useful when you only want a quick look at a large data set.

Choosing variables and their order

“If you omit the VAR statement, PROC PRINT prints all variables in the data set.” With a VAR statement, variables print in the order you list them. An ID statement replaces the observation number with the formatted values of the listed variables; ID variables appear before VAR variables, and a variable named in both appears twice. For a research listing, ID participant; is a natural way to keep each row identifiable without the observation-number column.

Totals

The SUM statement totals the values of numeric variables, and SUMBY limits the number of sums produced when you use BY. These are useful for a quick check against a control total, but a statistical summary belongs in a summary procedure, not in a listing.

The data table below lists the PROC PRINT statements and options used in this guide with their documented effects.

How to read PROC PRINT output

By default the output has a column of observation numbers followed by one column per variable, headed by the variable name. Reading it for data checks comes down to four points:

  • Row identity. The observation number is the row’s position in the data set, not an identifier from your study. If you sorted or subset the data, the numbers describe the data set you printed. Use ID or print a real identifier variable.
  • Headings. Without LABEL you see variable names; with it you see labels, and SPLIT= sets the character that breaks long labels over lines.
  • Sections. With BY, each BY group is its own section, and with N= the count appears after your explanatory text.
  • Formats. A FORMAT statement in the step controls how values are displayed; in Example 3 the statement format price dollar7.2 cost dollar7.2; displays the price and cost values as currency.

The documentation’s Example 3 produces HTML output by default, with no ODS statement needed. An RTF file is produced by wrapping the step in ods rtf file='your_file.rtf' startpage=no; and ods rtf close;; STARTPAGE=NO stops a page break at the start of each BY group, while PAGEBY still controls breaks.

Troubleshooting PROC PRINT

The output is huge or slow to read

PROC PRINT prints every observation and, without VAR, every variable. Limit the columns with VAR, and limit the rows during checks with OPTIONS OBS=n;, as the documentation does with obs=10. Remember to reset the option before running the analysis steps, since it is a system option and not an option of one procedure.

BY groups look wrong

The documentation example sorts the data by the BY variables before printing, so sort first, as in step 2 above. The BY statement also accepts NOTSORTED, which is a deliberate choice about how the data are grouped, not a fix for data you simply forgot to sort. If your sections are not the groups you expect, print the BY variable’s values and look for stray spellings or case differences.

Observation numbers are in the way

NOOBS “suppresses the observation number in the output.” If you want the column but under another heading, OBS="column-header" specifies the heading for the column that identifies each observation by number.

Column headings are cryptic

LABEL “uses variables’ labels as column headings.” It only helps if labels exist: add a LABEL statement in the step, as in the example, or confirm with PROC CONTENTS that the data set carries them.

DOUBLE or BLANKLINE has no visible effect

The documentation states that “DOUBLE inserts a blank line between observations,” and notes that it has no effect on HTML output. BLANKLINE= is the option to use for spacing between observations in styled output, and STYLE= controls appearance, for example the headings in the documentation’s example.

Pages break in the wrong place

PAGEBY BY-variable controls page ejects before a page is full. For RTF, add STARTPAGE=NO to the ODS statement as described above.

Free alternatives to PROC PRINT

Other free tools can show a table of values. The table compares the basic task of listing a few rows or columns, not an exact translation of PROC PRINT. For a broader comparison of the two main statistical environments, see R vs SAS.

Tool Documented approach Difference to check
R (utils package) head() returns the first or last parts of a vector, matrix, array, table, data frame or function; the default n is 6. A negative n excludes that many rows from the end, which has no direct equivalent in PROC PRINT options.
Python with pandas DataFrame.to_string renders a DataFrame to a console-friendly tabular output; columns selects a subset and index=False omits row labels. The index is printed by default (index defaults to True), and na_rep defaults to ‘NaN’, so missing-value display differs from SAS.

Whichever tool you use, compare the printed rows with the source file for a few records identified by a study ID, rather than relying on the first rows alone.

Sources

Data: PROC PRINT statements and options with documented effects

Compiled from the SAS documentation pages for the PRINT procedure: each statement or option used in this guide with the effect the documentation states for it.

PROC PRINT statements and options with documented effects
Statement or optionWhere usedDocumented effectDocumentation page
PROC PRINT DATA=Procedure statementSpecifies the SAS data set to print.https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002291718.htm
NOOBSProcedure statementSuppresses the observation number in the output.https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002291718.htm
OBS="column-header"Procedure statementSpecifies a column heading for the column that identifies each observation by number.https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002291718.htm
LABELProcedure statementUses variables' labels as column headings.https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002291718.htm
SPLIT='split-character'Procedure statementControls line breaks in column headings.https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002291718.htm
NProcedure statementPrints the number of observations in the data set, in BY groups, or both, with explanatory text.https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002291718.htm
DOUBLEProcedure statementInserts a blank line between observations; no effect on HTML output.https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/n1h2bc0rkcufgwn11accg1uiksto.htm
VARStatementSelects variables and determines their order; all variables print if omitted.https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/n1cfqafrw9xvoln1sz5oed59lyf3.htm
IDStatementIdentifies observations by formatted values of the listed variables instead of observation numbers.https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/p10qiuo2yicr4qn17rav8kptnjpu.htm
BYStatementProduces a separate section for each BY group.https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/p10qiuo2yicr4qn17rav8kptnjpu.htm
PAGEBYStatementControls page ejects before a page is full.https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/p10qiuo2yicr4qn17rav8kptnjpu.htm
SUMStatementTotals values of numeric variables.https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/p10qiuo2yicr4qn17rav8kptnjpu.htm
SUMBYStatementLimits the number of sums.https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/p10qiuo2yicr4qn17rav8kptnjpu.htm

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · full access

Ask about PROC PRINT in SAS: Syntax, Options and Examples

Full access: large monthly usage, up to 10 source passages behind each answer, and MCP and API access for Claude Code, Codex and other CLIs. Cancel any time.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →