If your dataset is large (more than 100 observations or more than 10 variables), you will most likely want SAS to read your data directly from an external file in which you have it saved. This is easily done if your data are in a text file, such as a *.txt file.
SAS statements to read the data from a text file (Method 1):
SAS needs to be told two things: a SAS name for the dataset, and the name of the external text file. These are accomplished with one SAS statement:
The PROC IMPORT statement has two options:
SAS statements always start with a keyword and end with a semicolon.
In addition, use the REPLACE option to assure that SAS overwrites pre-existing versions of your dataset. Each time you run PROC IMPORT, it will attempt to create the requested dataset. If you do not specify REPLACE, it will not create a new dataset (i.e., it will leave the old copy active). This can cause great confusion, as you correct your dataset and SAS appears to ignore the changes (because the old copy is still being used).
SAS statements to read the data from a text file (Method 2):
SAS needs to be told four things: a SAS name for the dataset, the external file name, names for each of your variables, and any special format for those variables. These are accomplished with three SAS statements:
The DATA statement starts this process by naming the dataset, for example DATA one;
The INFILE statement is used to identify the external file, and options needed to read the file.
The INPUT statement names the variables and describes how they should be read in.
example 1: Using INPUT to read a tab-delimited file
DATA one; INFILE 'c:\dawg\tab1.txt' DLM='09'X DSD FIRSTOBS=2;
example 2: Using a formatted INPUT to read a tab-delimited file
If a variable has letter values, use the $ symbol after its name. Other formats that are commonly used are dates, for example MMDDYY8. specifies month-day-year data with the / separator and 8 characters wide (eg. 12/31/05). Otherwise the access instructions do not change, for example
example 3: Using PROC IMPOR T to read a tab-delimited file
An example of using PROC IMPORT is: