Syntax: DATASOURCE Procedure

The DATASOURCE procedure uses the following statements:

PROC DATASOURCE options ;
KEEP variable-list ;
DROP variable-list ;
KEEPEVENT event-list ;
DROPEVENT event-list ;
WHERE where-expression ;
RANGE FROM from TO to ;
ATTRIBUTE variable-list attribute-list ... ;
FORMAT variable-list format ... ;
LABEL variable="label" ... ;
LENGTH variable-list length ... ;
RENAME old-name=new-name ... ;

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 12.3.

Table 12.3 Summary of Syntax

Option

Description

Input Data File Options

FILETYPE=

type of input data file to read

INFILE=

fileref(s) of the input data

LRECL=

lrecl(s) of the input data

RECFM=

recfm(s) 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