pandas.read_sas¶
-
pandas.
read_sas
(filepath_or_buffer: Union[str, pathlib.Path, IO[~AnyStr]], format: Union[str, NoneType] = None, index: Union[Hashable, NoneType] = None, encoding: Union[str, NoneType] = None, chunksize: Union[int, NoneType] = None, iterator: bool = False) → Union[ForwardRef('DataFrame'), pandas.io.sas.sasreader.ReaderBase][source]¶ Read SAS files stored as either XPORT or SAS7BDAT format files.
- Parameters
- filepath_or_bufferstr, path object or file-like object
Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is expected. A local file could be:
file://localhost/path/to/table.sas
.If you want to pass in a path object, pandas accepts any
os.PathLike
.By file-like object, we refer to objects with a
read()
method, such as a file handler (e.g. via builtinopen
function) orStringIO
.- formatstr {‘xport’, ‘sas7bdat’} or None
If None, file format is inferred from file extension. If ‘xport’ or ‘sas7bdat’, uses the corresponding format.
- indexidentifier of index column, defaults to None
Identifier of column that should be used as index of the DataFrame.
- encodingstr, default is None
Encoding for text data. If None, text data are stored as raw bytes.
- chunksizeint
Read file chunksize lines at a time, returns iterator.
- iteratorbool, defaults to False
If True, returns an iterator for reading the file incrementally.
- Returns
- DataFrame if iterator=False and chunksize=None, else SAS7BDATReader
- or XportReader