Skip to main content
v2026.11,986 entries · CC-BY 4.0

PROC IMPORT in SAS: Syntax, Options and Troubleshooting

How PROC IMPORT reads CSV, tab-delimited and Excel files into a SAS data set, with documented defaults and fixes for wrong column types.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

PROC IMPORT is the Base SAS procedure that reads an external data file, such as a comma-delimited CSV file, a tab-delimited file or an Excel workbook, and writes it out as a SAS data set. You give it the file in the DATAFILE= option, name the output data set in OUT=, and let the DBMS= option (or the file extension) tell SAS which format to read. This guide covers the same task whichever way you search for it: sas proc import, proc import in sas or proc import sas. The syntax and defaults below come from the SAS documentation, Base SAS 9.3 Procedures Guide and SAS/ACCESS 9.3 Interface to PC Files Reference.

What PROC IMPORT is used for in research

Most research data does not start life as a SAS data set. Survey exports, instrument output, registry extracts and collaborator spreadsheets typically arrive as delimited text or Excel files, and an analysis in SAS needs them as a data set first. PROC IMPORT performs that conversion in one step, and because it is code rather than a menu click, the conversion can be saved in a program, rerun, and reviewed alongside the rest of an analysis.

That reproducibility is the main reason to prefer code over a point-and-click import: the file path, the format, the delimiter and the rules for guessing variable types are all written down, so a collaborator or an auditor can see exactly how the raw file became the analysis data set. The SAS documentation describes the procedure as importing data from an external data source into a SAS data set, and notes that for delimited files it determines each variable’s attributes by scanning the data.

If you are checking an imported data set against a second version of the same data, the PROC COMPARE guide covers that follow-up step, and the PROC CONTENTS guide covers inspecting the variables PROC IMPORT created.

How to install or access it

PROC IMPORT is a Base SAS procedure, so it is available wherever Base SAS is licensed. Reading delimited text files and, on the platforms listed below, Excel files with DBMS=XLS or DBMS=XLSX uses the file formats technology and lists no additional product requirement in the PC Files reference. Importing from a database table by name (the TABLE= option in the Base SAS documentation) requires SAS/ACCESS Interface to PC Files together with the DBMS= option. Some Excel routes need more: DBMS=EXCEL needs the Microsoft ACE or Jet provider and runs on Microsoft Windows, and DBMS=EXCELCS needs the PC Files Server.

How you obtain SAS is a licensing question handled on the vendor’s own site. For the academic routes and the desktop interface, see our guides to SAS for academic users and SAS Enterprise Guide. This page does not state any prices.

Step-by-step: import a CSV file with PROC IMPORT

1. Write the basic statement

The general form in the Base SAS documentation is:

PROC IMPORT DATAFILE="filename" | TABLE="tablename"
    OUT=<libref.>SAS-data-set
    <DBMS=identifier>
    <REPLACE>;
RUN;

For a comma-delimited file whose name ends in .CSV, the documentation says the DBMS= option is not required, so a minimal import looks like this (the path is a placeholder for your own file):

proc import datafile="C:datasurvey.csv"
    out=work.survey
    replace;
run;

2. Name the output data set

OUT= takes a one-level or two-level name. According to the documentation, a one-level name is written to the USER library if you have assigned one, and to the WORK library otherwise. WORK is temporary, so use a two-level name such as mylib.survey when the data set must survive the SAS session.

3. Say which format to read when the file is not .CSV

For other delimited files, set DBMS= as follows, as listed in the SAS/ACCESS PC Files reference: DBMS=CSV for comma-delimited, DBMS=TAB for tab-delimited, and DBMS=DLM for any other delimiter. With DBMS=DLM, add a DELIMITER= statement; the reference says DELIMITER= applies only to DBMS=DLM and takes a single character or a hexadecimal value written as 'nn'x. For example, a space-delimited file can use DELIMITER='20'x.

4. Add the file-specific statements before RUN

GETNAMES=, DATAROW= and GUESSINGROWS= are statements, not options on the PROC IMPORT line: they go after the PROC IMPORT statement and before RUN. A tab-delimited example consistent with the reference’s own examples:

proc import datafile="C:datareadings.txt"
    out=work.readings
    dbms=tab
    replace;
    getnames=yes;
    datarow=2;
    guessingrows=100;
run;

5. Use REPLACE deliberately

Without REPLACE, the documentation says the procedure does not overwrite an existing data set of the same name. With it, the existing data set is replaced. In a script that is run repeatedly, REPLACE keeps the run from stopping at the second execution; in a one-off import into a permanent library it is worth leaving off so you cannot silently overwrite earlier work.

6. Importing an Excel workbook

The PC Files reference lists these Excel identifiers for DBMS=:

DBMS= value File formats Requirement stated Platforms stated
XLSX Excel 2007, 2010 None listed (file formats technology) Windows, Linux, UNIX
XLS Excel 5.0, 95, 97, 2000, 2002, 2003 None listed (file formats technology) Windows, Linux, UNIX
EXCEL Excel 97 through 2010, Excel 4.0 and 5.0 Microsoft ACE or Jet provider Microsoft Windows
EXCELCS Excel workbook (remote) PC Files Server; Excel driver on Windows Windows, Linux, UNIX

The same page gives this example for reading a range of cells from an .xlsx file under UNIX, and states that transcoding is not supported for DBMS=XLS:

proc import datafile="fieldtypes.xlsx"
    out=small dbms=xlsx;
    range=colsb_d;
run;

For Excel files the reference says the first eight rows are scanned to decide whether a column is numeric or character. That is different from the delimited-file default described below, so a column that looks wrong after an Excel import has a different cause than a wrong CSV column.

Output and how to read it

A successful PROC IMPORT creates the data set named in OUT= and writes a note to the SAS log. Read the log first, then look at the data set itself. Check three things: the number of observations and variables against what you expect from the source file; the variable names; and the type of each variable.

Variable names depend on GETNAMES=. Its default is YES, which uses the first row of the file as variable names; the reference says invalid characters in those names are converted to underscores, so a header such as an occupancy code with a space becomes Occupancy_Code. With GETNAMES=NO, SAS generates names instead. The reference text says generic names are F1, F2 and so on, while one of its own example outputs shows VAR1, VAR2, so look at the data set rather than assuming a prefix.

Variable types come from the scan. The Base SAS documentation says that for delimited files, PROC IMPORT scans the first 20 rows to determine variable attributes, that values are read as character, and that a variable becomes numeric when a date or time format or a numeric informat applies to its values. Use PROC CONTENTS to list variable names, types and lengths, then PROC PRINT with an observation limit to eyeball the values.

Parsing behaviour for delimited files, also from the PC Files reference: a delimiter inside a quoted value is treated as character data and the quotes are removed, two consecutive delimiters produce a missing value, and trailing empty variables are set to missing.

Troubleshooting

A character column is truncated, or a numeric column came in as character

This is the type-guessing rule at work: with the default of 20 rows scanned, a column can be given the wrong type or attributes if the first 20 rows do not represent the rest of the file. The documented fix is the GUESSINGROWS= statement. Its default is 20, and the allowed range is 1 to 2147483647, scanning from the first row. Raise it so that the scan covers the rows that show the true variation. The reference also says the default can be changed in the SAS Registry, and that GUESSINGROWS= describes types only, not lengths.

The file already exists as a SAS data set and the step stops

Add REPLACE if overwriting is intended; without it the procedure will not overwrite an existing data set.

The first data row is being read as variable names or as data

Check GETNAMES= and DATAROW= together. DATAROW= defaults to 2 when GETNAMES=YES and to 1 when GETNAMES=NO. With GETNAMES=YES it must be 2 or greater, and with GETNAMES=NO it must be 1 or greater, so a file with a title block above the header needs DATAROW= set past the block.

A WHERE= or other data set option is rejected

The Base SAS documentation states that data set options such as WHERE= cannot be used when importing delimited, CSV or tab-delimited files. Import first, then subset in a DATA step or PROC SQL step.

A long record is cut off

When DATAFILE= is a fileref, the record length defaults to 256 and the documentation gives a maximum of 32767 for the FILENAME LRECL= option. Only the DISK device type is supported in that FILENAME statement; TEMP is not.

The delimiter is not a comma or a tab

Use DBMS=DLM with a DELIMITER= statement. A delimited file whose extension is not .CSV needs an explicit DBMS= (CSV, TAB or DLM) because only a .CSV extension lets you omit it.

Use the data table below as a quick reference for the defaults and valid values behind each of these fixes.

Free alternatives to PROC IMPORT

SAS is licensed software. If you cannot use it, or need to read the same file from another environment, both R and Python have documented delimited-file readers with comparable defaults:

Tool Reader function Documented defaults How column types are set
R (utils package) read.csv header = TRUE, sep = "," Columns are read as character then converted with type.convert, unless colClasses is given
Python (pandas) read_csv sep is a comma; header='infer' The dtype argument sets types for the whole data set or for individual columns

For R workflows see our guides to loading data into R and read.table in R. The common thread is the same lesson PROC IMPORT teaches: when a tool guesses column types from the file, state the types yourself whenever the guess matters for the analysis.

Frequently asked questions

What does PROC IMPORT do in SAS?

It reads an external file, such as CSV, tab-delimited or Excel, and creates a SAS data set from it. You specify the file with DATAFILE=, the output with OUT=, and the format with DBMS= when the extension does not make it clear.

Do I need DBMS= to import a CSV file?

Not when the file name ends in .CSV, according to the Base SAS 9.3 documentation. For tab-delimited files use DBMS=TAB, and for any other delimiter use DBMS=DLM with a DELIMITER= statement.

How many rows does PROC IMPORT scan to guess variable types?

20 for delimited files by default, which GUESSINGROWS= can change within 1 to 2147483647. For Excel files the PC Files reference says the first eight rows are scanned.

How do I overwrite an existing data set?

Add REPLACE to the PROC IMPORT statement. Without it, the procedure does not overwrite an existing data set.

Where does the data set go if I give a one-level name?

To the USER library if one is assigned, and to WORK otherwise, so it disappears when the session ends unless you use a permanent two-level name.

Can I use WHERE= when importing a CSV file?

No. The documentation says data set options such as WHERE= cannot be used when importing delimited, CSV or tab-delimited files.

Sources

  • SAS Institute, Base SAS 9.3 Procedures Guide, “The IMPORT Procedure”: https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/n18jyszn33umngn14czw2qfw7thc.htm (read 2026-11-14)
  • SAS Institute, SAS/ACCESS 9.3 Interface to PC Files: Reference, “Delimited Files”: https://support.sas.com/documentation/cdl/en/acpcref/63181/HTML/default/p07k868np8cd18n1teen33x5bym7.htm (read 2026-11-14)
  • SAS Institute, SAS/ACCESS 9.3 Interface to PC Files: Reference, “IMPORT Procedure”: https://support.sas.com/documentation/cdl/en/acpcref/63181/HTML/default/p0jf3o1i67m044n1j0kz51ifhpvs.htm (read 2026-11-14)
  • R Core Team, R documentation for utils read.table / read.csv: https://stat.ethz.ch/R-manual/R-devel/library/utils/html/read.table.html (read 2026-11-14)
  • pandas documentation, pandas.read_csv (v3.1.1): https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html (read 2026-11-14)

Data: PROC IMPORT options for delimited files: defaults and valid values (SAS 9.3 documentation)

Compiled from the Base SAS 9.3 Procedures Guide and the SAS/ACCESS 9.3 Interface to PC Files Reference: for each PROC IMPORT option or statement used with delimited files, where it is written, its documented default and its valid values.

Period covered: SAS 9.3 documentation.

PROC IMPORT options for delimited files: defaults and valid values (SAS 9.3 documentation)
Option or statementWhere writtenDocumented defaultValid values or limits
DATAFILE=PROC IMPORT statementNone (required for file imports)Path and file name, or a fileref
OUT=PROC IMPORT statementOne-level name goes to USER library if assigned, otherwise WORKSAS-data-set name
DBMS=PROC IMPORT statementNot needed for a .CSV fileCSV, TAB, DLM (also JMP for JMP files)
REPLACEPROC IMPORT statementOff: an existing data set is not overwrittenKeyword
GETNAMES=Statement before RUNYES (first row used as variable names)YES or NO
DATAROW=Statement before RUN2 if GETNAMES=YES, 1 if GETNAMES=NO2 or greater with YES; 1 or greater with NO
GUESSINGROWS=Statement before RUN201 to 2147483647
DELIMITER=Statement before RUN (DBMS=DLM only)BlankSingle character or hexadecimal 'nn'x

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about PROC IMPORT in SAS: Syntax, Options and Troubleshooting

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →