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:
"$dta->{nvar} variables; $dta->{nobs} observations\n"
;
Variable names and types:
join
(
','
, @{
$dta
->{varlist} } ) .
"\n"
;
for
(
my
$i
= 0;
$i
<
$dta
->{nvar}; ++
$i
) {
"$dta->{varlist}[$i] has SQL type "
.
$dta
->sqlType(
$i
) .
"\n"
;
}
Retrieve data
while
(
my
@a
=
$dta
->readRow ) {
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.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 65:
Non-ASCII character seen before =encoding in 'Latrémolière.'. Assuming UTF-8