sas_ascii_reader {asciiSetupReader}R Documentation

Read fixed-width ASCII file using SAS Setup file.


sas_ascii_reader() and spss_ascii_reader() are used when you need to read an fixed-width ASCII (text) file that comes with a setup file. These file combinations are sometimes referred to as .txt+.sps,, .dat+.sps, or The setup file provides instructions on how to create and name the columns, and fix the key-value pairs (sometimes called value labels). This is common in government data, particular data produced before 2010.


  value_label_fix = TRUE,
  real_names = TRUE,
  keep_columns = NULL,
  coerce_numeric = TRUE



Name of the ASCII (.txt) file that contains the data. This file may be zipped with a file extension of .zip.


Name of the SAS Setup file - should be a .sas or .txt file.


If TRUE, fixes value labels of the data. e.g. If a column is "sex" and has values of 0 or 1, and the setup file says 0 = male and 1 = female, it will make that change. The reader is much faster is this parameter is FALSE.


If TRUE fixes column names from default column name in the SPSS setup file (e.g. V1, V2) to the name is says the column is called (e.g. age, sex, etc.).


Specify which columns from the dataset you want. If NULL, will return all columns. Accepts the column number (e.g. 1:5), column name (e.g. V1, V2, etc.) or column label (e.g. VICTIM_NAME, CITY, etc.).


If TRUE (default) will make columns where all values can be made numeric into numeric columns.Useful as FALSE if variables have leading zeros - such as US Census FIPS codes.

See Also

spss_ascii_reader For using an SPSS setup file

Other ASCII Reader functions: spss_ascii_reader()


# Text file is zipped to save space.
dataset_name <- system.file("extdata", "",
  package = "asciiSetupReader")
sas_name <- system.file("extdata", "",
  package = "asciiSetupReader")

## Not run: 
example <- sas_ascii_reader(dataset_name = dataset_name,
  sas_name = sas_name)

# Does not fix value labels
example2 <- sas_ascii_reader(dataset_name = dataset_name,
  sas_name = sas_name, value_label_fix = FALSE)

# Keeps original column names
example3 <- sas_ascii_reader(dataset_name = dataset_name,
  sas_name = sas_name, real_names = FALSE)

## End(Not run)
# Only returns the first 5 columns
example <- sas_ascii_reader(dataset_name = dataset_name,
  sas_name = sas_name, keep_columns = 1:5)

[Package asciiSetupReader version 2.5.1 Index]