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.
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:
. import sas ACCESS BROADBND COMPOTHX DIALUP HISPEED LAPTOP using 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
|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|
|hispeed||str1||%1s||Broadband (high speed) Internet|
|service such as cable, fiber|
|optic, or DSL servi|
|laptop||str1||%1s||Laptop or desktop|