Proc Import [4-7]

Importing Text Delimited File

Text file is another file type that is commonly imported by Proc Import.

Let's look at the TXT_Practice_01.txt file.

The text file contains three columns:

  • Name
  • Age
  • Gender

The file is also a space-delimited file, which means the values are all separated by a single space.

Let's look at the code to import this file:

When importing a space-delimited file, you need to do the following:

  1. Specify the file in the FILENAME statement (obviously)
  2. Specify DLM as the DBMS option
  3. Optionally, specify the space as the delimiter. 

Note:​

  • The DELIMITER statement is optional for space-delimited files since SAS, by default, assumes the delimiter to be a space. You do not need to specify it when importing a space-delimited file.

The code above will import the text file properly into SAS:

Comma Delimited Files

Importing a comma-delimited file is similar to importing a space-delimited file. 

Let's take a look at the text file named TXT_Practice_02.txt:

The file is a comma-delimited text file, and each value is separated by a comma.

​Below is the code to import this file:

The DELIMITER statement tells SAS the file is a comma-delimited file.

SAS will then import the file accordingly:

In the next section, we will learn how to import a tab-delimited file.


Exercise

Use Proc Import to import the file named TXT_Practice_03.txt.

Get Hint

Get Solution