Giter VIP home page Giter VIP logo

statadtajs's Introduction

#StataDtaJS

StataDtaJS is a JavaScript library with a single purpose: read a Stata dataset file from disk and create a JavaScript object containing all of the file's information.

StataDta.js works with dta versions 114, 115, and 117 (the main versions used with Stata 11, 12, and 13), and, in particular, can read strL data in version 117.

StataDta.js uses JavaScript's DataView to read the dataset, and so can be used with any modern browser that supports DataView. It's likely that this library will work with a "polyfill" like jDataView, but this has not been verified.

##Usage

Use the function StataDta.open to open a dta file. The function takes two arguments and returns an object. The first argument should be a DataView object, the second a boolean determining whether each row should be input as a JSON object or an array.

##Example

The included example.html is a simple example that reads a dta file into the global variable dta which can then be inspected from a browser console. Here is example input and output from the Chrome browser after loading the auto.dta file that comes with Stata13:

> dta
  Object {_dsFormat: 117, _littleEndian: true, _nvar: 12, _nobs: 74, _dataLabel: "1978 Automobile Data"…}
> dta._varlist
  ["make", "price", "mpg", "rep78", "headroom", "trunk", "weight", "length", "turn", "displacement", "gear_ratio", "foreign"]
> dta._varvals[0]
  Object {make: "AMC Concord", price: 4099, mpg: 22, rep78: 3, headroom: 2.5…}
> dta._vallabs
  Object {origin: Object}
> dta._vallabs['origin']
  Object {0: "Domestic", 1: "Foreign"}

##Side effects:

StataDta.js adds

  • the function startsWith to the String prototype if it does not already exist
  • the function getUTF8 to the DataView prototype
  • the function getBlob to the DataView prototype

##Author James Fiedler

email: jrfiedler at gmail dot com

statadtajs's People

Contributors

jrfiedler avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

chsilvac

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.