Lab Orientation
In the beginning (you
only need to do this the first time)
1. Log in as guest (no password required)
2. You'll see two tabs on the bottom of the screen, click on the "Guest Account" tab and then click on the Winter_2001_Roster.url link to Internet Explorer.
3. Find your name and the lab ID. Your 9 digit student ID is your password in this laboratory. Logout of the guest account (you'll need to close the tab and then click on the word
Special on the menu bar) and then login again using your lab ID and your student ID this time instead of "guest".
Now that you are
logged in as you and not as guest
(if you still can't login please go to this page: http://www.stat.ucla.edu/~vlew/stat11/labs/Initialization.pdf)
1. When you successfully login on your personal account, you should see some folders and icons on the extreme right hand of the screen. You have a personal folder that is the same as your lab ID, please locate it. This is the folder where all things you create will be stored. Another important folder is called "Items for Student1" this contains programs you can use in this lab.
2. Double click on "Items for Student1" to open the folder.
3. Double click on the "My Stata" icon to start Stata.
A bit about Stata
When you start Stata in these labs, you get 4 windows and a menu bar popping up. The windows have titles like: Review, Variables, Stata Results, and Command. The two most important windows are Stata Results and Command. If you close a window accidently, go to the menu bar and find the word "WINDOWS" and then click on the name of the window you closed to reopen it. To move between windows, just click on the window to activate it.
Be careful when you're clicking on the review or variables window. If there is something in those windows and you click on it, whatever you clicked on will appear in the command window. This is handy sometimes, but not right now.
Let's get the dataset
1. Retrieve the dataset for Lab #1 by issuing this entire command (quotes and all) in the command window:
use
"http://www.stat.ucla.edu/~vlew/stat11/labs/lahmda.dta"
and press enter. Stata will go onto the internet to get the data for you. For the remainder of the quarter, you will retrieve data in this way.
This "use" command followed by the URL for the dataset can be issued from any computer running Stata and connected to the internet. If you have a personal copy of Stata and are working from home, if you are logged in via a modem, you can get the dataset copied to your home computer.
2. Take a look at how Stata has changed now that you've successfully issued the use command and the dataset name. There should be a copy of the use command in your review window, a list of variables in your variables window and a copy of your use command in the results window. If this is what your version of Stata looks like now….
3. …then you are ready to do a little work with Stata
Some basics about
Stata itself
1. Stata is unusual when it comes to printing. Essentially, Stata is not well designed to print directly. It's preferred that you save your session and then print it out from another source, like a word processing program.
2. Stata uses log files. Essentially, a log file is a recording of your computer session. You can print log files easily or export them to other programs -- such as word processing programs.
3. To open a log file, issue the following command:
log using filename
where filename is anything you want to call it. Stata will automatically create a new folder in your personal folder called Stata Data and store log files that you create in that folder.
To save a log file, you basically need to close it. To do that, you issue the command:
log close
For example, if I issue the command
log using mylab1
Stata creates a file called mylab1.log
then when I issue
log close
I can no longer add information to mylab1.log using Stata, but now I can print out, modify, copy, or e-mail the file named mylab1.log.
4. To print out or edit log files, in this lab you can use Apple Works and it's Word Processing capabilities to read in your file and then modify it or print it out. Otherwise, if you don't like Appleworks or would prefer to do this elsewhere, you'll need to move your file.
By the way, you can print out graphs in the lab on the printers by clicking the "print" icon in Stata. (It's the third icon on the Stata menu bar). If you want to save a graph, click on the word FILE then Save Graph, then give the graph a name and click "Save". Stata will save your graphs to your Stata Data file.
Getting your files
out of this lab
Frequently, you will want to get your files out of this lab. There are 2 ways basically:
Method 1:
1. Log out of your account, then go to one of the two computers in the back of the room and log back in.
2. Insert a floppy disk in the drive
3. Find your file in your folder, just drag that file onto the icon of your floppy disk. Release and it should copy it.
Method 2:
The other way is to e-mail it to yourself as a attachment. Go back to the folder that says "Items for Student 1" and click on the WebMail icon.
Follow the WebMail instructions. When you've successfully configured your account, click on the word "NEW" and send a message to yourself. You can attach the log file you create by filling in the information on the lines that say Attach 1, Attach 2, or Attach 3. Generally, you'll just have one attachment so just use the first one.
I find it easiest to use the "Browse" button in WebMail and to locate my log file in the "my folder" (the Stata Data folder).
Getting Help From
Stata
Stata has two forms of help. The HELP command and the SEARCH command. The difference is this, to use HELP, the word that follows it must be a real Stata command such as:
help use
If you type this you will learn all about the use command (more than you need to know).
Search is the command you use if you don't know the actual command. So, suppose you interested in calculating a statistic called a median. If you tried "help median", Stata will complain with a response like:
. help median
help for median not
found
try help contents or search median
so issue the command
search median
and you'll get more than you ever wanted to know about how to calculate a median.
Some Basic Stata
Commands
Stata commands are always lowercase.
1. To get a description of the dataset, type the command
describe
or
codebook
2. To see the actual values of every variable in the dataset, type the command
list
to see specific variables, you must give them names such as
list tractid medfam00
medfam90
3. To generate basic statistics, issue the command
summarize
and you'll get all of the variables, or
summarize, detail
which will give you all of the variables and a lot of statistics, some useful, some not. The comma separates the option from the actual Stata command.
summarize medfam90,
detail
Will only give you the statistics for that variable, in detail. By the way, that stands for the median family income in 1990 for some areas in Los Angeles.
4. To leave Stata type:
clear
then type
exit
A Bit about the data
You will be using this dataset for lab 1 and will learn more about it then, but for those of you who must know right now, this is economic and demographic (population) data for the county of Los Angeles in 2000. Here is a result of a describe in Stata:
. describe
Contains data from lahmda.dta
obs: 1,652 2000 Los Angeles
Economic and
Demographic Data
vars: 11 9 Jan 2001 18:34
size: 72,688 (98.5%
of memory free)
-------------------------------------------------------------------------------
1.
tractid float %9.0g Census Tract Identifier
2.
inclevel str8 %9s
Income Level of Tract
3.
medpct float %9.0g Percentage of Los Angeles
Median Income
4.
lamedian long %12.0g
Los Angeles Median Income
5.
medfam00 long %12.0g 2000 Median Family Income in
Dollars
6.
medfam90 long %12.0g
1990 Median Family Income in
Dollars
7.
totpop int %8.0g
Total Population of the Tract
8.
pctminor float %9.0g Percentage Minority in the Tract
9.
minorpop int %8.0g
Minority Population of the Tract
10.
owners int %8.0g Number
of Homeowners in the
tract
11.
renters int %8.0g
Number of renters in the tract
-------------------------------------------------------------------------------
Sorted by:
tractid
As you can see there are 11
variables and1,652 observations. A
census tract is a unit of geography used by the United States Census to
organize information on the population. Los Angeles county is divided into
1,652 of these tracts. Each tract has a
unique identifier and has associated information about the households residing
within that tract. So for example a
list command reveals (next page):
. list
Observation 1
tractid 1011 inclevel Upper medpct 138.88
lamedian 52100 medfam00 72356 medfam90 54212
totpop 7458 pctminor 20.81
minorpop 1552
owners 1802 renters 2449
And you would interpret this information as the tractid is 1011,
it is an Upper income census tract
its income percentage as compared with the county median is 138.88%
the county median is $52,100
its median family income in 2000 was 72,356
its median family income in 1990 was 54,212
the total population in 2000 is 7,458 people
the percentage minority is 20.81%
the total number of minorities is 1,552
the total number of home owning households is 1,802
the total number of renting households is 2,449
if you are interesting in finding your census tract in this dataset (if you live in Los Angeles) you can go to this web page:
http://tier2.census.gov/ctsl/ctsl.htm
If you are interested in a map of census tracts, that's a lot more complicated. If you are REALLY interested in this kind of research (you don't need it for this class) ask me and I'll point you to a web site that can generate census tract maps. It is not easy to use.