## Handy Tricks

This page covers a few odds and ends that can be helpful at times.

### Using the "if" command

Let's say you want to analyze only a subset of the data. For example, let's say you're still interested in what affects attitudes toward federal spending on science and technology, but you want to look specifically at women's attitudes, not men's. You can use the "if" command to subset the data accordingly. So, for a crosstab of science and party id, you would type

tab science partyid if female==1

For a regression of science on partyid, you would type

reg science partyid if female==1

The output is only a regression examining the relationship between *partyid *and *science* among female respondents. It's important to note that it takes two equals signs.

### Additional model fit statistics

After you run a regression, you can simply type "fitstat" and hit enter to get a wide range of additional model fit statistics.

For example, think back to the bivariate and multivariate OLS regressions from the last page. How might you decide whether the model with only *partyid *is better, or if the model with *partyid*, *female*, *highschool*, and *collegedegree *is better? The AIC value -- AIC stands for the Akaike Information Criterion -- can give you such an assessment. If adding additional variables to your model nonetheless produces a lower AIC value than the model with fewer variables, you have some statistical justification for the choice.

### Setting "more" off

Often if you tell Stata to do something that involves a lot of output, it will only display a screen worth of it and include a blue link at the bottom that reads "---more---." In order to see everything, you have to keep clicking "---more---." If you would prefer Stata just to spit out the entire result at once, you can tell Stata to do so by turning the "more" option off. Simply run the following command:

set more off

Now this shouldn't happen -- but it probably sometimes will, because that's just how Stata rolls.

### Loading an Excel spreadsheet into Stata

Often research projects start with a dataset you collect and create using Excel. You can load a dataset from Excel into Stata directly, but the easiest way is simply to copy and paste the dataset into the Data Editor (follow the instructions here and make sure you tell Stata to treat the top row as variable names if you copy that in as well).

### Loading an SPSS, etc., dataset into Stata

Every statistical software has its own quirks, one of which is a unique file format for datasets. Stata uses a .dta extension, while SPSS might use .por. The easiest way to open an SPSS file in Stata is to use a program called Stat/Transfer. This software is unfortunately not widely available on the Barnard campus, but many computer labs at Columbia have it in their Quantiative Apps folder along with Stata. It's simple to use. Just select the dataset and tell Stat/Transfer you want it to become a .dta Stata file. If you don't have access to Stat/Transfer, you can also do this conversion in the open source statistical software R, which can be downloaded for free online.

### << Back to Regression Analysis

Continue to More Advanced Regression Models >>

### Return to Table of Contents

Questions, comments, concerns?

Send an email to the Empirical Reasoning Lab

Or drop in during the Lab's open hours.