FileIO.jl integration for Stata, SPSS, and SAS files
Branch: master
Clone or download
Latest commit 156c76a Feb 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test Add test for Base.show(io::IO, source::StatFile) Feb 13, 2019
.codecov.yml StatFiles.jl generated files. Jun 8, 2017
.gitignore StatFiles.jl generated files. Jun 8, 2017
.travis.yml Update CI config for julia 1.1 Jan 3, 2019
LICENSE.md Update to julia 0.7 Jul 20, 2018
NEWS.md Add support for 'application/vnd.dataresource+json' MIME type Feb 4, 2019
README.md Update README Aug 28, 2018
REQUIRE Update REQUIRE Aug 28, 2018
appveyor.yml Update CI config for julia 1.1 Jan 3, 2019

README.md

StatFiles

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Build Status Build status StatFiles codecov.io

Overview

This package provides load support for Stata, SPSS, and SAS files under the FileIO.jl package.

Installation

Use Pkg.add("StatFiles") in Julia to install StatFiles and its dependencies.

Usage

Load a Stata, SPSS, or SAS file

To read a Stata, SPSS, or SAS file into a DataFrame, use the following julia code:

using StatFiles, DataFrames

df = DataFrame(load("data.dta"))

The call to load returns a struct that is an IterableTable.jl, so it can be passed to any function that can handle iterable tables, i.e. all the sinks in IterableTable.jl. Here are some examples of materializing a Stata, SPSS, or SAS file into data structures that are not a DataFrame:

using StatFiles, DataTables, IndexedTables, TimeSeries, Temporal, Gadfly

# Load into a DataTable
dt = DataTable(load("data.dta"))

# Load into an IndexedTable
it = IndexedTable(load("data.dta"))

# Load into a TimeArray
ta = TimeArray(load("data.dta"))

# Load into a TS
ts = TS(load("data.dta"))

# Plot directly with Gadfly
plot(load("data.dta"), x=:a, y=:b, Geom.line)

Using the pipe syntax

load also support the pipe syntax. For example, to load a Stata, SPSS, or SAS file into a DataFrame, one can use the following code:

using StatFiles, DataFrame

df = load("data.dta") |> DataFrame

The pipe syntax is especially useful when combining it with Query.jl queries, for example one can easily load a Stata, SPSS, or SAS file, pipe it into a query, then pipe it to the save function to store the results in a new file.