Reads Fixed-Width ASCII Data Files (.txt or .dat) that Have Accompanying Setup Files (.sps or .sas)

Lets you open a fixed-width ASCII file (.txt or .dat) that has an accompanying setup file (.sps or .sas). These file combinations are sometimes referred to as .txt+.sps,, .dat+.sps, or This will only run in a txt-sps or txt-sas pair in which the setup file contains instructions to open that text file. It will NOT open other text files, .sav, .sas, or .por data files. Fixed-width ASCII files with setup files are common in older (pre-2000) government data.

CRAN_Status_Badge Travis-CI BuildStatus AppVeyor BuildStatus Coveragestatus lifecycle


Some (usually older) data sets are only available in fixed-width ASCII files (.txt or .dat) that have an .sps (SPSS) or .sas (SAS) setup file explaining to the software how to read that file. These file combinations are sometimes referred to as .txt+.sps,, .dat+.sps, This package allows you to read in the data if you have both the fixed-width file and its accompanying setup file.


To install this package, use the code
# install.packages("devtools")


These parameters data and setup_file are the only ones requires to run the package though three optional parameters allow you to customize results.

data - A string containing the name of the data file setup_file - A string containing the name of the data file

Both files must be in your working directory or the string must contain the path to the file. Below is an example of reading in the example dataset - the original data and setup files can be found here.

data <- system.file("extdata", "",
             package = "asciiSetupReader")
setup_file <- system.file("extdata", "example_setup.sps",
             package = "asciiSetupReader")
example <- asciiSetupReader::read_ascii_setup(data = data,
setup_file = setup_file)
example[1:6, 1:4] # Look at first 6 rows and first 4 columns
## 1 SHR master file            Alabama  AL00112 Cit 50,000-99,999
## 2 SHR master file            Alabama  AL00112 Cit 50,000-99,999
## 3 SHR master file            Alabama  AL00112 Cit 50,000-99,999
## 4 SHR master file            Arizona  AZ00189       Cit < 2,500
## 5 SHR master file            Arizona  AZ00189       Cit < 2,500
## 6 SHR master file            Arizona  AZ00189       Cit < 2,500


asciiSetupReader 2.0.1

  • Fix problem where package didn't work with dev version of Haven.

asciiSetupReader 2.0.0

Major Changes

  • Adds a single function (read_ascii_setup) that will read in data for both .dat+.sps and pairs. This is just a helper function that calls spss_ascii_reader or sas_ascii_reader.
  • Adds function to create sps setup files.
  • Adds capacity for .sas reader to handle missing values.
  • Adds a function for users to parse the setup file (.sps or .sas) and get results. An accompanying vignette explains this function.
  • Adds a function to make your own .sps files (not .sas yet).

Minor Changes

  • Adds option to not coerce potentially numeric columns into numeric type. Useful in cases like dealing with Census FIPS codes that have leading zeros.
  • Miscellaneous bug fixes.
  • Fixes bug when missing values are an interval (e.g. -1 thru -8).

asciiSetupReader 1.4.0

  • Adds capacity to the SPSS reader to handle Missing Values.
  • Fixes bug where function fails if no value-labels are detected.
    • Applies both when setup file has no value-labels and if only select columns that have no value-labels.
  • Adds a huge number of tests.
  • Changes factor column to character columns.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2.2.0 by Jacob Kaplan, 2 months ago

Report a bug at

Browse source code at

Authors: Jacob Kaplan [aut, cre]

Documentation:   PDF Manual  

MIT + file LICENSE license

Imports data.table, haven, readr, stringr, zoo, shiny, miniUI, rstudioapi

Suggests covr, knitr, rmarkdown, testthat

See at CRAN