Parse::Stata::DtaReader - read Stata 8 and Stata 10 .dta files
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.
open my $fileHandle, '<', 'test.dta'; my $dta = new Parse::Stata::DtaReader($fileHandle);
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"; }
while ( my @a = $dta->readRow ) { print join( ',', @a ) . "\n"; }
Stata .dta format specification from: http://www.stata.com/help.cgi?dta http://www.stata.com/help.cgi?dta_113
It works for me, but has not been fully tested. Versions prior to 0.7 had serious errors in converting some data types. There are probably some similar bugs left.
All Stata missing values will be converted into a perl undef, losing the information about the type of missing value.
This code comes with ABSOLUTELY NO WARRANTY of any kind.
Written by Franck Latremoliere. Copyright (c) 2007, 2008 Reckon LLP. http://www.reckon.co.uk/staff/franck/
This program is free software; you can use, redistribute and/or modify it under the same terms as Perl itself (Artistic Licence or GNU GPL).
To install Parse::Stata::DtaReader, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::Stata::DtaReader
CPAN shell
perl -MCPAN -e shell install Parse::Stata::DtaReader
For more information on module installation, please visit the detailed CPAN module installation guide.