About Creating a SAS Data Set with a DATA Step
Creating a SAS Data File or a SAS View
You can create either a SAS data file, a data set that holds actual data, or a SAS view, a
data set that references data that is stored elsewhere. By default, you create a SAS data
file. To create a SAS view instead, use the VIEW= option in the DATA statement. With a
SAS view, you can process current input data values without having to edit your DATA
step. For example, you can process monthly sales figures without having to edit your
DATA step. Whenever you need to create output, the output from a SAS view reflects
the current input data values.
The following DATA statement creates a SAS view called Monthly_Sales.
data monthly_sales / view=monthly_sales;
The following DATA statement creates a data file called Test_Results.
data test_results;
Sources of Input Data
You select data-reading statements based on the source of your input data. There are at
least six sources of input data:
• raw data in an external file
• raw data in the jobstream (instream data)
• data in SAS data sets
• data that is created by programming statements
• data that you can remotely access through a SAS catalog entry, the clipboard, a data
URL, an email, an FTP protocol, a Hadoop Distributed File System, TCP/IP socket,
a URL, a WebDAV protocol, or through zlib services
• data that is stored in a Database Management System (DBMS) or other vendor's data
files.
Usually, DATA steps read input data records from only one of the first three sources of
input. However, DATA steps can use a combination of some or all of the sources.
Reading Raw Data: Examples
Example 1: Reading External File Data
The components of a DATA step that produce a SAS data set from raw data stored in an
external file are outlined here.
data Weight; 1
infile 'your-input-file'; 2
input IDnumber $ week1 week16; 3
WeightLoss=week1-week16; 4
run; 5
About Creating a SAS Data Set with a DATA Step 415