Load data from Stata, SAS and SPSS files into Julia tables
Author junyuan-chen
3 Stars
Updated Last
2 Years Ago
Started In
April 2021


Load data from Stata, SAS and SPSS files into Julia tables

CI-stable codecov PkgEval docs-stable docs-dev

ReadStatTables.jl is a Julia package for loading data from Stata, SAS and SPSS files into a Tables.jl-compatible table. It relies on ReadStat.jl, which is a Julia interface of the ReadStat C library, for parsing the data files. The same C library is also the backend for popular packages such as pyreadstat and haven.


ReadStatTables.jl adds the following features on top of the read support from ReadStat.jl.

  • A lightweight Tables.jl-compatible column table ReadStatTable for basic operations.
  • Integration of value labels via a customized array type LabeledArray.
  • Translation of date and time values into Julia time types Date and DateTime.

Quick Start

To load a data file located at data/sample.dta:

julia> using ReadStatTables

julia> tb = readstat("data/sample.dta")
5×7 ReadStatTable:
 Row │ mychar    mynum      mydate                dtime         mylabl           myord               mytime 
     │ String  Float64       Date?            DateTime?  Labeled{Int8}  Labeled{Int8?}             DateTime 
   1 │      a      1.1  2018-05-06  2018-05-06T10:10:10           Male             low  1960-01-01T10:10:10
   2 │      b      1.2  1880-05-06  1880-05-06T10:10:10         Female          medium  1960-01-01T23:10:10
   3 │      c  -1000.3  1960-01-01  1960-01-01T00:00:00           Male            high  1960-01-01T00:00:00
   4 │      d     -1.4  1583-01-01  1583-01-01T00:00:00         Female             low  1960-01-01T16:10:10
   5 │      e   1000.3     missing              missing           Male         missing  2000-01-01T00:00:00

For details, please see the documentation.

Used By Packages

No packages found.