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.
Look at the source code of dta2csv and dta2sql for working code examples.
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_114 http://www.stata.com/help.cgi?dta_113
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.
This code comes with ABSOLUTELY NO WARRANTY of any kind.
Copyright 2007, 2008, 2014 Reckon LLP and Franck Latrémolière. http://www.reckon.co.uk/staff/franck/
This is free software; you can redistribute it and/or modify it under the same terms as Perl.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Latrémolière.'. Assuming UTF-8
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.