This guide will take you through the steps of starting a Stata .do file, importing data, and doing
some analysis. Along the way, several useful functions will be introduced.
In your internet browser, go to
. This should bring you to a page that
offers you the chance to download a file called “ACC Basketball Players.csv.”
Download the file. My suggestion is to right-
click on the link, choose the “Save Link As…” option
from the context-menu, and save it to a folde
r you’ll remember, perhaps even the Desktop.
From the menu, go to Window > Do-file Editor > New Do-file. Or, hit Ctrl-8.
This is a Do-file, in which you will type commands for Stata to execute.
I suggest starting all Do-files with a description of what the file does. Anything on a line that
an “*” character will not be read and executed by Stata. Thus, the asterisk can be
called a comment character. You may want to begin your Do-file with something like:
* This file is my first Do-file, in which I load data and run a few
Next, I suggest you type the clear command, which will empty Stata’s memory every time you
run the Do-file from the beginning. You will also want to set memory to something larger (so
Stata can handle more data and more complicated operations:
set mem 400m
Now, find the file path that points to where you saved “ACC Basketball Players.csv” on your hard
drive. It might be something like “
ACC Basketball Players.csv”
You load this into Stata with the command:
insheet using "C:\Users\dbs9\Desktop\ACC Basketball Players.csv", comma
is the command for loading data, and
tells Stata that the file is a .csv, or
comma-separated value file.
At this point, you’ll want to
run your Do-file. You can do this in many ways:
On the Do-file editor menu, go to Tools > Do
Select all of the code you’ve written (Ctrl
A), and then hit the keyboard shortcut for “do,”
You can also run one line at a time. If your cursor is on a line of code, or selecting part of a
line or several lines of code, you can “do” that selection alone.