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 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
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 | ||||
device | ||||
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 | |
One of the first tasks in any research project is reading in data. import spss allows us to bring IBM® SPSS® files (version 16 or higher) and compressed IBM SPSS files (version 21 or higher) into Stata. We can import the entire dataset or only a subset of it. Dates, value labels, and missing values are all converted properly from SPSS to Stata format.
We want to use the General Social Survey (GSS) for 2018, which we have in SPSS (.sav) format. The GSS gathers demographic and socioeconomic information about individuals and also records their perceptions about social, cultural, and economic issues.
The dataset we are interested in is GSS2018.sav. To bring it into Stata, we open the dialog box by clicking on File > Import > SPSS data (*.sav). We select the GSS2018.sav dataset and get
We can now import all the data or only a subset.
In this case, we are interested in data about people's confidence in different institutions. We would like to see confidence in the military (CONARMY), business and industry (CONBIZ), Congress (CONCONG), and the courts and legal system (CONCOURT).
Note that the variables have uppercase names in this SPSS file. We want all of them to be in lowercase. Under Variable case:, we select the option Lower.
After clicking OK, our data are in Stata and are ready for us to analyze.
As always, we could have used the command line instead of the dialog box. Here is what we would have typed:
. import spss CONARMY CONBIZ CONCONG CONCOURT using GSS2018, case(lower)
Smith, T. W., M. Davern, J. Freese, and S. L. Morgan. 2019. General Social Surveys, 1972–2018 [GSS2018.sav]. Sponsored by National Science Foundation. Chicago: NORC.
1 data file (64,814 logical records) + 1 codebook (3,758 pp.). (National Data Program for the Social Sciences, no. 25).