Importing SAS/Stata files using pandas

Introduction to Importing Data in Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

SAS and Stata files

  • SAS: Statistical Analysis System
  • Stata: “Statistics” + “data”
  • SAS: business analytics and biostatistics
  • Stata: academic social sciences research
Introduction to Importing Data in Python

SAS files

  • Used for:
    • Advanced analytics
    • Multivariate analysis
    • Business intelligence
    • Data management
    • Predictive analytics
    • Standard for computational analysis
Introduction to Importing Data in Python

Importing SAS files

import pandas as pd
from sas7bdat import SAS7BDAT
with SAS7BDAT('urbanpop.sas7bdat') as file:
    df_sas = file.to_data_frame()
Introduction to Importing Data in Python

Importing Stata files

import pandas as pd
data = pd.read_stata('urbanpop.dta')
Introduction to Importing Data in Python

Let's practice!

Introduction to Importing Data in Python

Preparing Video For Download...