Reading and writing

read_dta read_stata write_dta

Read and write Stata DTA files.

read_sas write_sas

Read and write SAS files.

read_sav read_por write_sav read_spss

Read SPSS (SAV & POR) files. Write SAV files.

read_xpt write_xpt

Read and write SAS transport files

Labelled vectors

SAS, SPSS, and Stata share a simply concept of “labelled” vectors, which are similar to factors but a little more general. The labelled() class provides a natural representaion in R.

labelled_spss

Labelled vectors for SPSS

labelled is.labelled

Create a labelled vector.

print_labels

Print the labels of a labelled vector

as_factor

Convert input to a factor.

tagged_na

Both SAS and Stata supported tagged missing values, where a missing value can have multiple “types”, given by an letter from A through Z. tagged_na() provides a convenient way of representing these types of missing values in R by taking advantage of the binary representation of NA.

tagged_na na_tag is_tagged_na format_tagged_na print_tagged_na

"Tagged" missing values

Remove attributes

There are a number of SPSS/SAS/Stata features that have no direct equivalent in R. Haven preserves them so you can choose what do with them. To simply eliminate them, use one of the zap functions.

as_factor

Convert input to a factor.

labelled_spss

Labelled vectors for SPSS

labelled is.labelled

Create a labelled vector.

print_labels

Print the labels of a labelled vector

read_dta read_stata write_dta

Read and write Stata DTA files.

read_sas write_sas

Read and write SAS files.

read_sav read_por write_sav read_spss

Read SPSS (SAV & POR) files. Write SAV files.

read_xpt write_xpt

Read and write SAS transport files

tagged_na na_tag is_tagged_na format_tagged_na print_tagged_na

"Tagged" missing values

zap_empty

Convert empty strings into missing values.

zap_formats

Remove format attributes

zap_labels

Zap labels

zap_missing

Zap special missings to regular R missings

zap_widths

Remove display width attributes