Using the Imported Data in a DATA Step

Naming the Data Set with the DATA Statement

The DATA statement indicates the beginning of the DATA step and names the SAS data set to be created.
Syntax, DATA statement:
DATA SAS-data-set-1 <...SAS-data-set-n>;
SAS-data-set names (in the format libref.filename) the data set or data sets to be created.
Remember that a permanent SAS data set name is a two-level name. For example, the two-level name Clinic.Admit specifies that the data set Admit is stored in the permanent SAS library to which the libref Clinic has been assigned.

Specifying the Imported Data with the SET Statement

The SET statement specifies the SAS data set that you want to use as input data for your DATA step. When you import your external data using PROC IMPORT, you specify the name of the output data set using the OUT= option. Use the libref and data set name that you specified using the OUT= option as the SAS data set value for the SET statement.

SET Statement Syntax

Syntax, DATA step for reading a single data set:
DATA SAS-data-set;
SET SAS-data-set;
<...more SAS statements...>
RUN;
  • SAS-data-set in the DATA statement is the name of the SAS data set to be created.
  • SAS-data-set in the SET statement is the name of the SAS data set to be read.

Example: Using the SET Statement to Specify Imported Data

In this example, the DATA statement tells SAS to name the new data set, Boots, and store it in the temporary library Work. The SET statement in the DATA step specifies the output data set from the IMPORT procedure. You can use several statements in the DATA step to subset your data as needed. In this example, the WHERE statement is used with VAR1 to include only the observations where VAR1 is either South America or Canada.
proc import datafile="C:certdataoot.csv"
  out=shoes
  dbms=csv
  replace;
  getnames=no; 
run;
data boots;
  set shoes;
  where var1='South America' OR var1='Canada';
run;
Output 4.7 Results from the DATA Step Using the SET Statement
Results from DATA Step Using the SET Statement
Last updated: August 23, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.74.211