Skip Navigation
*To search for student contact information, login to FlashLine and choose "My Campus" tab.

Search by campus:

SAS Proc Print Basics Screenshots Tutorials

Proc print in SAS allows you to examine data, display particular variables of interest, display particular observations, and display a list report with column totals.

SAS 9.1.4 Proc Print 1

To generate a Default List Report:

Proc print data=train.sastraining;

run;

Note that the program starts with Proc Print. You then need to specify the data you are using with a data= statement. In this case, the data is in the 'train' library and is titled 'sastraining'.

SAS 9.1.4 Proc Print 2

If you want to select a particular variable or variables, you can do so with a VAR statement.

Proc print data=train.sastraining;

var Department;

run;

SAS 9.1.4 Proc Print 3

SAS by default, prints the observation numbers for each row (case). To omit that option, use the NOOBS option.

proc print data=train.satisfaction NOOBS;

run;

Subsetting Data with the WHERE Statement

  • Allows you to select the particular observations based on particular criteria.
  • Can be used with most SAS procedures ("IF" statements are generally used in the Data step though).
  • Operands are the variables and observations.
  • Operators: comparisons, logical, special, and functions.

SAS 9.1.4 Proc Print 7

Above is a table of some comparison operators

SAS 9.1.4 Proc Print 4

If you are interested in examining only those participants whose department is Psychology:

proc print data=train.sastraining NOOBS;

where department= 'Psychology';

run;

WHERE Logical Operators

  • And (&) used if both expressions are true, then the compound expression is true.
  • OR (|) used if either expression is true, then the compound expression is true.
  • Not (^) can be combined with other operators to reverse the logic of the comparison.

SAS 9.1.4 Proc Print 5

In the above example, the output is constrained to the Psychology department and faculty who have been with the institution more than 10 years.

proc print data=train.sastraining NOOBS;

where departments= 'Psychology' and years>10;

run;

SAS 9.1.4 Proc Print 8

In the above example, we are interested including either Anthropology or Psychology in the report.

proc print data=train.sastraining NOOBS;

where department= 'Psychology' or department= 'Anthropology'

run;

WHERE Special Operators

  • BETWEEN-AND -- used to select observations in which the value of the variable falls within a range of values.
  • CONTAINS? -- used when one wants to select observations that include the specified substring.

SAS 9.1.4 Proc Print 6

In the above example, we are interested in results for cases where the faculty had been employed at the institution for between 10 and 15 years.

proc print data=train.sastraining NOOBS;

where years between 10 and 15;

run;

SAS 9.1.4 Proc Print 9

In the above example, we are interested in narrowing the department, but are unsure of the exact label.

proc print data=train.sastraining NOOBS;

where Department? 'Nurse';

run;

Column Totals

  • Can provide a Total.
  • Can also provide subtotals if data is printed in groups.

SAS 9.1.4 Proc Print 10

In the above example, we are interested in a total for the Years column.

proc print data=train.sastraining NOOBS;

sum years;

run;

For additional questions or assistance, contact Tina Ughrin.

Research Software Tutorial Survey

1. This tutorial was helpful. This field is required

2. Suggestions for changes or additions to this tutorial.

3. How did you find out about this webpage?