SAS Base Programming study materials
SAS Base Programming study resources

SAS Base Programming key terms

SAS Base Programming · Get comfortable with the vocabulary.

libref

A short nickname (up to eight characters) that you assign to a SAS library so that programs can refer to the folder or database where data sets are stored without writing the full path each time.

Related: LIBNAME statement, SAS data set
LIBNAME statement

A statement that associates a libref with a physical location, such as a folder of files, so SAS can read and write data sets stored there for the rest of the session.

Related: libref, SAS data set
SAS data set

A file that SAS creates and reads, containing data organized into rows (observations) and columns (variables), plus descriptive information about the file such as variable names, types, and labels.

Related: Variable attributes, SET statement
Program Data Vector (PDV)

The area of memory where SAS builds one observation at a time during DATA step execution; it holds all variables, including ones created in the step, and its contents are written out when the step reaches the end of an iteration.

Related: SET statement, Array
Variable attributes

The properties that describe a variable in a data set: its name, type (character or numeric), length in bytes, label, format, informat, and position. Changing them changes how values are stored or displayed.

Related: ATTRIB statement, INFORMAT statement
INFORMAT statement

A statement that tells SAS how to read raw character values and convert them into stored values, for example turning the text 01/15/2020 into a numeric date. Informats can be assigned in a DATA step or with an ATTRIB statement.

Related: ATTRIB statement, Variable attributes
ATTRIB statement

A DATA step statement used to set one or more variable attributes, such as label, format, informat, and length, in a single place before the variables are read or created.

Related: Variable attributes, INFORMAT statement
Data set options

Instructions written in parentheses after a data set name that change how SAS reads or writes that data set for one step, such as KEEP=, DROP=, RENAME=, WHERE=, OBS=, and FIRSTOBS=.

Related: SET statement, WHERE statement
PROC IMPORT

A procedure that reads an external file, such as a delimited text file or an Excel workbook, determines its structure, and creates a SAS data set from it, optionally saving the generated code for reuse.

Related: SAS data set, libref
INPUT statement

A DATA step statement that reads values from an external file or from instream data lines and assigns them to variables, using list, column, formatted, or named input.

Related: Program Data Vector (PDV), INFORMAT statement
SET statement

A DATA step statement that reads observations from one or more existing SAS data sets, one observation per iteration, so the step can modify, filter, or create new variables from existing data.

Related: Program Data Vector (PDV), MERGE statement
MERGE statement

A DATA step statement that combines observations from two or more SAS data sets side by side into one output observation, matching rows when a BY statement is used and requiring the input data sets to be sorted first.

Related: SET statement, BY statement
SAS date value

A numeric value equal to the number of days between January 1, 1960, and a given date; SAS stores dates this way, and a date constant such as '01JAN2020'd lets you write one in code.

Related: INFORMAT statement, Variable attributes
Subsetting IF statement

A statement in the DATA step that tests a condition and, when the condition is false, stops processing the current observation so that it is not written to the output data set.

Related: WHERE statement, Program Data Vector (PDV)
WHERE statement

A statement that selects observations before they enter the DATA step or procedure, so only rows that meet the condition are read and processed.

Related: Subsetting IF statement, Data set options
BY statement

A statement that tells SAS to process data in groups defined by the values of one or more variables, which must be sorted or indexed first; it enables group-level processing and BY-line output in procedures.

Related: MERGE statement, FIRST. and LAST. variables
RETAIN statement

A DATA step statement that keeps a variable's value from one iteration of the DATA step to the next instead of resetting it to missing at the start of each iteration.

Related: SUM statement, Program Data Vector (PDV)
SUM statement

A statement of the form variable + expression that adds a value to a variable and automatically retains that variable across iterations, treating missing values as zero and initializing the variable to zero.

Related: RETAIN statement, Iterative DO loop
Iterative DO loop

A group of statements executed repeatedly a set number of times, controlled by DO index = start TO stop BY increment, often used with an array to process several variables in one pass.

Related: Array, SUM statement
PROC SORT with NODUPKEY

A procedure that orders a data set's observations by one or more variables; the NODUPKEY option removes observations that have duplicate values of the BY variables, keeping the first occurrence.

Related: BY statement, SAS data set
User-defined format

A custom label mapping created with PROC FORMAT and a VALUE statement that groups or relabels stored values for display or analysis without changing the underlying data values.

Related: Variable attributes, PROC FREQ
FIRST. and LAST. variables

Temporary variables that SAS creates during BY-group processing; FIRST.variable equals 1 for the first observation in a group and LAST.variable equals 1 for the last, and both are 0 otherwise.

Related: BY statement, Subsetting IF statement
LAG function

A function that returns the value of its argument from a previous observation during DATA step execution, so a step can compare the current row with an earlier one.

Related: RETAIN statement, BY statement
Array

A group of SAS variables referenced by a single name and an index; arrays let you process many variables with a loop, although they store no data themselves and exist only while the DATA step runs.

Related: Iterative DO loop, Program Data Vector (PDV)
Character-manipulation functions

Built-in functions such as SUBSTR, SCAN, TRIM, STRIP, UPCASE, and CATX that extract, search, combine, or change the case of character values, often used to clean text before storing or reporting it.

Related: Variable attributes
_ERROR_ automatic variable

A temporary variable that SAS sets to 1 when an execution-time error occurs during a DATA step iteration and to 0 otherwise; writing it to a data set helps you locate records that caused problems.

Related: Execution-time error, PUTLOG statement
_N_ automatic variable

A temporary variable that counts how many times the DATA step has iterated, starting at 1 for the first iteration; it is often used to number rows or to limit processing to specific observations.

Related: _ERROR_ automatic variable, Subsetting IF statement
Compile-time error

A problem SAS detects while translating a step before any data is read, such as a misspelled keyword, unbalanced quotes, or an unknown function; the step does not execute and error messages appear in the log.

Related: Execution-time error
Execution-time error

A problem that occurs while a step is running, such as reading a character value into a numeric variable or dividing by zero; SAS sets ERROR to 1 and handles the problem according to the error and options in effect.

Related: Compile-time error, _ERROR_ automatic variable
PUTLOG statement

A statement that writes a message, including variable values, to the SAS log during execution, which is useful for tracing program logic and diagnosing why a DATA step produces unexpected results.

Related: _ERROR_ automatic variable, Execution-time error
OPTIONS ERRORS= system option

A system option that sets the maximum number of observations for which SAS writes error messages to the log; 0 means no limit, and a small number helps you scan a long log.

Related: Execution-time error, Compile-time error
PROC PRINT

A procedure that displays the observations of a SAS data set as a simple listing, with optional LABEL, BY, and SUM statements and data set options controlling which rows and columns appear.

Related: ODS destination, PROC REPORT
PROC REPORT

A procedure that produces detailed or summary reports with columns you define, supporting grouping, statistics, computed columns, and the ability to send the report to a SAS data set instead of a listing.

Related: DEFINE statement, COMPUTE block
DEFINE statement

A PROC REPORT statement that specifies how a report column is used and displayed, setting options such as usage (group, order, across, analysis), a display label, a format, and a statistic.

Related: PROC REPORT, COMPUTE block
COMPUTE block

A section in PROC REPORT, begun by COMPUTE and ended by ENDCOMP, where you write DATA step statements to calculate new values or apply conditional formatting for a column or for the whole report.

Related: DEFINE statement, PROC REPORT
Output Delivery System (ODS)

The part of SAS that takes procedure output and routes it to one or more destinations, controlling the form of the output, such as HTML, PDF, RTF, or a SAS data set, and the style applied.

Related: ODS destination, ODS SELECT and EXCLUDE
ODS destination

A specific output target opened with an ODS statement, for example ODS HTML, ODS PDF, or ODS LISTING; destinations can be open at the same time and each receives the output sent to it.

Related: Output Delivery System (ODS)
ODS SELECT and EXCLUDE

Statements that control which procedure output objects are sent to the open destinations during a session, letting you suppress or keep specific tables and reports.

Related: Output Delivery System (ODS), ODS destination
PROC FREQ

A procedure that builds frequency and cross-tabulation tables for character or numeric variables, showing counts, percentages, and optionally chi-square statistics; the TABLES statement lists the variables to tabulate.

Related: PROC TABULATE, User-defined format
PROC TABULATE

A procedure that produces summary tables in which class variables define rows and columns and analysis variables are summarized by statistics, using a TABLE statement to describe the table layout.

Related: PROC FREQ, ODS destination