https://github.com/queryverse/statfiles.jl
FileIO.jl integration for Stata, SPSS, and SAS files
https://github.com/queryverse/statfiles.jl
julia queryverse
Last synced: 3 months ago
JSON representation
FileIO.jl integration for Stata, SPSS, and SAS files
- Host: GitHub
- URL: https://github.com/queryverse/statfiles.jl
- Owner: queryverse
- License: other
- Created: 2017-06-08T21:10:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-22T04:47:43.000Z (almost 5 years ago)
- Last Synced: 2025-04-10T09:20:55.661Z (3 months ago)
- Topics: julia, queryverse
- Language: Julia
- Size: 225 KB
- Stars: 26
- Watchers: 3
- Forks: 9
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# StatFiles
[](http://www.repostatus.org/#active)
[](https://travis-ci.org/queryverse/StatFiles.jl)
[](https://ci.appveyor.com/project/queryverse/statfiles-jl/branch/master)
[](http://codecov.io/github/queryverse/StatFiles.jl?branch=master)## Overview
This package provides load support for Stata, SPSS, and SAS files
under the [FileIO.jl](https://github.com/JuliaIO/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:
````julia
using StatFiles, DataFramesdf = DataFrame(load("data.dta"))
````The call to ``load`` returns a ``struct`` that is an [IterableTable.jl](https://github.com/queryverse/IterableTables.jl), so it can be passed to any function that can handle iterable tables, i.e. all the sinks in [IterableTable.jl](https://github.com/queryverse/IterableTables.jl). Here are some examples of materializing a Stata, SPSS, or SAS file into data structures that are not a ``DataFrame``:
````julia
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:
````julia
using StatFiles, DataFramesdf = load("data.dta") |> DataFrame
````The pipe syntax is especially useful when combining it with [Query.jl](https://github.com/queryverse/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.