Stata Help

A Typical Stata Session

I present the following basic Stata session using both the user interface (navigating through menus and Stata's readymade buttons) and the Command window, wherein you simply type the command to Stata.

First, I will simply open the program. This is done by navigating to the Applications Menu, opening the Stata folder and selecting StataSE. You could also click on StataSE if it was in your dock or Start Menu.

Next, I will open a data file that has already been prepared (for example, data on fruit consumption). From within Stata, this simply requires clicking the Open button button on the toolbar. I can also go to File => Open navigate to my data and click Open. My third option is to type use [dataset name] into the Command window if I am in the right directory (click here to learn more about changing directories). 

After I open the data file, I realize I omitted my latest participant, so I open the data editor. The easiest way to do this is simply click the Data editor button button on the toolbar. You can also get there by going Data=> Data Editor or typing edit into the Command window.

Once I am in the editor, I simply type each value in, hitting enter before switching to a new cell. When I am done, I hit the little red button to close the data window (the same as in any other program); the apple(cmd)key and w will also work. 

Now that I have completed my data set, I will run some descriptives on it. The fastest way to do this is to type summarize into the Command window. This will cause the results window to display extremely basic information (N, mean, SD, min, and max) about every variable. You can also go to Data => Describe data => Summary statistics and hit enter (leaving the variable field blank) which does the same thing and offers the same options explored below.

I can also type summarize apples to only look at information about my apple consumption variable.

In addition, summarize takes "if" arguments. Thus you can also type summarize [variable] if [nonstring variable] > [number]

For more on "if" see the tutorial page.

Now that I've described my variables, I decide to do a histogram of the relevant one. In this case, I simply type histogram apples, freq. into the Command window. See the the tutorial page for more on making histograms in Stata.

Now I want to run an analysis. Since I am particularly curious how various hunger primes effect apple consumption, I want to compare number of apples consumed by hunger-prompt. To do this I simply type ttest apples, by(condi) into the Command window. Or, I could also go to Statistics => Summaries, Tables, Tests => Classical Tests of Hypotheses and select one of the t-tests. Either way, this command causes the Results window to display the results of my test. To learn more about running t-tests in Stata, see the t-test instructions.

Having obtained these two results, I will now print them. To print the histogram I simply click the Print icon icon located in the Graph window.

Now assuming I'm done, I type save, replace to make sure Stata saves my latest version of the data over the previous ones. I didn't do anything of particular note, so I will not save a copy of my Review window (though clicking on the Review window and going File => Save would allow me to do so (see the tutorials page for more on keeping logs of what you do). Finally, I type exit to quit the program.

Back to Program Overview

Forward to Basic Tutorial