Search Shortcut cmd + k | ctrl + k
read_stat

Read data sets from SAS, Stata, and SPSS with ReadStat

Maintainer(s): mettekou

Installing and Loading

INSTALL read_stat FROM community;
LOAD read_stat;

Example

-- Create a table from a SAS .sas7bdat file
CREATE TABLE data AS FROM 'data.sas7bdat';
-- Create a table from an SPSS .sav or .zsav file
CREATE TABLE data AS FROM 'data.sav';
CREATE TABLE data AS FROM 'data.zsav';
-- Create a table from a Stata .dta file
CREATE TABLE data AS FROM 'data.dta';
-- If the file extension is not .sas7bdat, .sav, .zsav, or .dta,
-- invoke the read_stat function for the right file type
CREATE TABLE other_data AS FROM read_stat('data.other_extension', format = 'sas7bdat');
CREATE TABLE other_data AS FROM read_stat('data.other_extension', format = 'sav');
CREATE TABLE other_data AS FROM read_stat('data.other_extension', format = 'dta');
-- Override the character encoding with an `iconv`` encoding name,
-- see https://www.gnu.org/software/libiconv/
CREATE TABLE other_data AS FROM read_stat('latin1_encoded.sas7bdat', encoding = 'iso-8859-1');

About read_stat

Usage

Parameters

Name Description Type Default
format The format of the input file, when its extension does not indicate it, either 'sas7bdat', 'sav', or 'dta' VARCHAR NULL
encoding The character encoding of the input file, as defined by iconv, see https://www.gnu.org/software/libiconv/ VARCHAR NULL

Added Functions

function_name function_type description comment examples
read_stat table NULL NULL []