DATASOURCE Procedure

Syntax: DATASOURCE Procedure

The following statements are available in the DATASOURCE procedure:

The PROC DATASOURCE statement is required. All the rest of the statements are optional.

The DATASOURCE procedure uses two kinds of statements, subsetting statements and attribute statements. Subsetting statements provide selection of time series data over selected time periods and cross sections from the input data file. Attribute statements control the attributes of the variables in the output SAS data set.

The subsetting statements are the KEEP, DROP, KEEPEVENT, and DROPEVENT statements (which select output variables); the RANGE statement (which selects time ranges); and the WHERE statement (which selects cross sections). The attribute statements are the ATTRIBUTE, FORMAT, LABEL, LENGTH, and RENAME statements.

The statements and options used by PROC DATASOURCE are summarized in Table 3. The rest of this section provides detailed syntax information about each of these statements, beginning with the PROC DATASOURCE statement. The remaining statements are described in alphabetical order.

Table 3: Functional Summary

Option Description
Input Data File Options
FILETYPE= Type of input data file to read
INFILE= Filerefs of the input data
LRECL= LRECLs of the input data
RECFM= RECFMs of the input data
ASCII Character set of the incoming data
EBCDIC Character set of the incoming data
Output Data Set Options
OUT= Write the extracted time series data
OUTALL= Information on time series and cross sections
OUTBY= Information on only cross sections
OUTCONT= Information on only time series variables
OUTEVENT= Write event-oriented data
OUTSELECT= Control reporting of all or only selected series and cross sections
INDEX Create single indexes from BY variables for the OUT= data set
ALIGN= Control the alignment of SAS date values
Subsetting Option and Statements
INTERVAL= Select periodicity of series to extract
KEEP Time series to include in the OUT= data set
DROP Time series to exclude from the OUT= data set
KEEPEVENT Events to include in the OUTEVENT= data set
DROPEVENT Events to exclude from the OUTEVENT= data set
WHERE Select cross sections for output
RANGE Time range of observations to be output
Assigning Attributes Options and Statements
FORMAT Assign formats to variables in the output data sets
ATTRIBUTE FORMAT= Assign formats to variables in the output data sets
LABEL Assign labels to variables in the output data sets
ATTRIBUTE LABEL= Assign labels to variables in the output data sets
LENGTH Control the lengths of variables in the output data sets
ATTRIBUTE LENGTH= Control the lengths of variables in the output data sets
RENAME Assign new names to variables in the output data sets


Last updated: June 19, 2025