Select Page

The PROC IMPORT method in SAS is used to read and transform external data files into SAS datasets. It’s a simple approach to import data from numerous file types (such as Excel, CSV, and text files) into SAS for further analysis. Here’s a quick rundown of how PROC IMPORT works:

  1. Syntax Fundamentals:

PROC IMPORT’s fundamental syntax is as follows:

PROC IMPORT DATAFILE=”path_to_external_file” OUT=SAS_dataset_name

< options>;


DATAFILE: The path to the external data file that you wish to import.

OUT: The name of the SAS dataset that will be constructed to hold the imported data is specified.

<options>: DBMS, REPLACE, SHEET, GETNAMES, and other parameters can be used to customize the import procedure.

  • The DBMS option, which describes the type of external file format you are importing, is one of the most significant parameters in PROC IMPORT. The following are common DBMS option values:

XLSX is an extension for Excel files.

CSV stands for Comma-Separated Values (CSV).

TAB is used to denote tab-delimited text files.

DLF is used to represent delimited text files with user-defined delimiters.

  • The REPLACE option specifies whether an existing SAS dataset with the same name should be replaced. If you include REPLACE and there is already a dataset with the same name, it will be overwritten.
  • Option GETNAMES: The GETNAMES option determines whether the first row of the imported file contains variable names. If GETNAMES is given, SAS will utilise the first row of the resultant dataset as variable names.
  • SHEET Option (for Excel Files): When importing data from an Excel workbook with several sheets, you may use the SHEET option to indicate which sheet to import.
  • Here’s an easy example of importing data from a CSV file:

PROC IMPORT DATAFILE=”C:\path\to\mydata.csv”





This code imports data from “mydata.csv” into an SAS dataset named “mydata” and assumes variable names are in the first row of the CSV file.

PROC IMPORT is a valuable tool for swiftly bringing in external data for analysis into SAS. However, for more difficult data transformation and cleaning operations, more SAS processes and DATA steps may be required to prepare the data as needed.