October 2019
Beginner to intermediate
674 pages
16h 43m
English
Pandas can read two file formats from SAS – SAS xports (.XPT) and SAS data files (.sas7bdat).
The read_sas() function helps read SAS files. Here, a SAS data file has been read and displayed as a pandas dataframe:
df = pd.read_sas('sample.sas7bdat')df
This results in the following output:

The chunksize and iterator arguments help in reading the SAS file in groups of the same size. If the SAS data file that was used earlier is read with a chunksize of 10, then the 51 records will be divided into six groups, as shown in the following code:
rdr = pd.read_sas('sample.sas7bdat', chunksize=10)for chunk ...Read now
Unlock full access