Reckon LLP > Parse-Stata-DtaReader > Parse::Stata::DtaReader

Download:
Parse-Stata-DtaReader-0.711.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.711   Source  

NAME ^

Parse::Stata::DtaReader - read Stata 8 and Stata 10 .dta files

OVERVIEW ^

This module reads Stata 8 and Stata 10 .dta files.

The API is object oriented: create a new instance of Parse::Stata::DtaReader by providing a handle to the .dta file, and then use attributes and methods of that object to obtain the data.

SYNOPSIS ^

Look at the source code of dta2csv and dta2sql for working code examples.

Open a .dta file

    open my $fileHandle, '<', 'test.dta';
    
    my $dta = new Parse::Stata::DtaReader($fileHandle);

Retrieve general information

Number of variables and observations:

    print "$dta->{nvar} variables; $dta->{nobs} observations\n";

Variable names and types:

    print join( ',', @{ $dta->{varlist} } ) . "\n";
    
    for (my $i = 0; $i < $dta->{nvar}; ++$i) {
        print "$dta->{varlist}[$i] has SQL type " .
            $dta->sqlType($i) . "\n";
    }

Retrieve data

    while ( my @a = $dta->readRow ) {
        print join( ',', @a ) . "\n";
    }

SOURCES ^

Stata .dta format specification from: http://www.stata.com/help.cgi?dta_114 http://www.stata.com/help.cgi?dta_113

BUGS ^

It works for me, but has not been fully tested.

All Stata missing values will be converted into a perl undef, losing the information about the type of missing value.

NO WARRANTY ^

This code comes with ABSOLUTELY NO WARRANTY of any kind.

AUTHOR ^

Copyright 2007, 2008, 2014 Reckon LLP and Franck Latrémolière. http://www.reckon.co.uk/staff/franck/

LICENCE ^

This is free software; you can redistribute it and/or modify it under the same terms as Perl.

syntax highlighting: