Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The DATASOURCE Procedure

Syntax

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:

  1. subsetting statements, which control what time series, time periods, and cross sections are extracted from the input data file
  2. attribute statements, which 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 10.2.

Table 10.2: Summary of Syntax
Description Statement Option
Input Data File Options   
specify the character set of the incomingPROC DATASOURCEASCII
dataPROC DATASOURCEEBCDIC
specify the type of input data file to readPROC DATASOURCEFILETYPE=
specify the fileref(s) of the input data file(s)PROC DATASOURCEINFILE=
specify the lrecl(s) of the input data files(s)PROC DATASOURCELRECL=
specify the recfm(s) of the input data files(s)PROC DATASOURCERECFM=
   
   
Output Data Set Options   
write the extracted time series dataPROC DATASOURCEOUT=
output the descriptive information on the time series variables and cross sectionsPROC DATASOURCEOUTALL=
output the descriptive information on the cross sectionsPROC DATASOURCEOUTBY=
output the descriptive information on the time series variablesPROC DATASOURCEOUTCONT=
write event-oriented dataPROC DATASOURCEOUTEVENT=
control whether all or only selected series and cross sections be reportedPROC DATASOURCEOUTSELECT=
create single indexes from BY variables for the OUT= data setPROC DATASOURCEINDEX
control the alignment of SAS Date valuesPROC DATASOURCEALIGN=
   
Subsetting   
specify the periodicity of series to be extractedPROC DATASOURCEINTERVAL=
specify the time series variables to be included in the OUT= data setKEEP 
specify the time series variables to be excluded from the OUT= data setDROP 
specify the events to be included in the OUTEVENT= data setKEEPEVENT 
specify the events to be excluded from the OUTEVENT= data setDROPEVENT 
select cross sections for outputWHERE 
specify the time range of observations to be outputRANGE 
   
Assigning Attributes   
assign formats to the output variablesFORMAT 
 ATTRIBUTEFORMAT=
assign labels to variables in the output data setsLABEL 
 ATTRIBUTELABEL=
control the lengths of the output variablesLENGTH 
 ATTRIBUTELENGTH=
assign new names to the output variablesRENAME 

PROC DATASOURCE Statement

KEEP Statement

DROP Statement

KEEPEVENT Statement

DROPEVENT Statement

WHERE Statement

RANGE Statement

ATTRIBUTE Statement

FORMAT Statement

LABEL Statement

LENGTH Statement

RENAME Statement

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.