Home  /  Products  /  Features  /  Import data from SAS

<-  See Stata's other features


  • Import a SAS file or a subset of it into Stata

  • Import SAS value labels

  • Convert dates and times from SAS to Stata format

  • Handle missing values

One of the first tasks of any research project is reading in data. import sas allows us to import SAS® data from version 7 or higher into Stata. We can import the entire dataset or only a subset of it. With import sas we may also import value labels. Dates, value labels, and missing values are all converted properly from SAS to Stata format.

Let's see it work

We have a SAS dataset that contains Connecticut housing data provided by the US Census Bureau's American Community Survey.

The dataset is named psam_h09.sas7bdat. To import it into Stata, we open the import sas dialog box by clicking on File > Import > SAS data (*.sas7bdat). We select psam_h09.sas7bdat and get


We can now import all the data or only a subset.

In this case, we want to import information-related communication and technology. Specifically, we import variables recording whether the household has internet access (ACCESS) and whether that internet is dial-up service (DIALUP) or high-speed internet (HISPEED). We also import variables recording whether they have a laptop or desktop (LAPTOP) or other computer equipment (COMPOTHX). In addition, we import the variable indicating whether they have a cellular data plan (BROADBND).

Note that the variables have uppercase names in this SAS file. We want all of them to be in lowercase. Under Variable case: we select the option Lower.


We can now click OK to import the data.

As always, we could have used the command instead of the dialog box. Here is what we would have typed:

  psam_h09.sas7bdat", case(lower)

In either case, the data are now in Stata and ready to be analyzed.

. describe

 Contains data
  obs:        85,778                          PSAM_H09
 vars:             6
Storage Display Value
Variable name type format label Variable label
access str1 %1s Access to the Internet
broadbnd str1 %1s Cellular data plan for a
smartphone or other mobile
compothx str1 %1s Other computer equipment
dialup str1 %1s Dial-up service
hispeed str1 %1s Broadband (high speed) Internet
service such as cable, fiber
optic, or DSL servi
laptop str1 %1s Laptop or desktop
Sorted by: Note: Dataset has changed since last saved.

Tell me more

Learn more about importing a SAS dataset into Stata in the Stata Data Management Reference Manual; see [D] import sas.

Learn more about Stata's data importing tools in the Stata Data Management Reference Manual; see [D] Overview of importing data into Stata.