Using STATA on the Leland System II
—A
Guide to Managing Your Files on UNIX—
Prepared by Moonhawk Kim
Department of Political Science
Stanford University
October 12, 2000
This guide is prepared for students of Political Science 100A/200A Fall 2000 and is a follow-up to “Using STATA on the Leland System—A Guide to Setting Up Your Computer”. This guide provides a very bare minimum instruction on using UNIX operating system to use STATA and assumes that your computer has been already configured to use an X client to connect to Stata on the Leland system.
Downloading the Data Files to Your Computer:
1. Go to the class web site at www.stanford.edu/class/polisci100a
2. Go to the Homework and Handout page.
3. Right-mouse-click and hold (on Macs simply click and hold) on the dataset you want to download (either the lifeexp data or the dyteach.zip file)
4. A menu should pop up giving you various choices. Look for “Save this target as…” (on Macs “Save this link as…”) and go to that menu. Let go of the mouse button.
5. A box will pop up asking you to specify where you want to save the file and also to specify the name. Choose a directory location where you want the data file to be saved. Go to the bottom of the box where it says “Format” and choose save as “Source” rather than as “Text”.
6. Click “OK”.
7. Now you should have lifexp.dta and dyteach.zip in the directory you specified. (If you have Unzip and have expanded the dyteach.zip file, that’s fine. If you don’t have the program, don’t worry about it. We’ll come back to that a simpler way later.)
Getting files to your Leland account:
1. In order for you to use STATA on the Leland system, the data files you want to analyze need to be uploaded to your Leland account. The program to do that on PCs is WS_FTP and on Macs is Fetch. If you have installed the Stanford network software on your computer, you should find the respective program on your computer. Otherwise obtain it from the Stanford computing site (See “Using STATA on the Leland System” for more info on the site).
2. Open WS_FTP (or Fetch).
3. You will be presented with a box asking for host, user name and password. Type in transfer.stanford.edu for host, your own username and your password. Press return on your keyboard to connect.
4. You should now be connected to your Leland account. In WS_FTP, your Leland account directory shows up on the right-hand side (in Fetch, only your Leland account directory shows up). You can tell that it’s your account, because on top of the directory window is your username.
5. Open the directory (or folder) on your own computer—not in WS_FTP or Fetch—where you saved the data files by downloading from the course web site.
6. Select the data files and drag them directly over to the window showing your Leland account directory. Let go of the files, and they should transfer over to your Leland account. Both WS_FTP and Fetch will show the progress in transferring the files.
7. Once the transfer completes, go ahead and quit WS_FTP (or Fetch).
Using the Data Files:
1. Log in to your Leland account using Samson. (See “Using STATA on the Leland System” for more info)
2. Type ls to see the contents of your directory. You should see lifeexp.dta and dyteach.zip among some other files and directories.
3. If you uploaded the still-zipped version of the dyteach data file, at the prompt in your Leland account, type unzip dyteach.zip The computer will take a few moments to expand it.
4. Type ls again to see the updated contents of your directory. You should now see dyteach.dta as well as dyteach.zip. You can delete dyteach.zip, which you don’t need anymore, by typing rm dyteach.zip and typing yes at the confirmation prompt. Type ls again to see that dyteach.zip has indeed been deleted.
5. Start up Stata by opening your X window application and typing in stata command from your Leland telnet account. (See “Using STATA on the Leland System” for more info)
6. At the Stata prompt—the period—type use lifeexp The data file should load smoothly and give you the comment (with updated iiswar data).
7. At this point, you can run all the normal Stata commands as usual.
Managing the Data Files:
1. As you work on this problem set and the future ones, your Leland directory will get cluttered with data files. Accordingly, you may want to create a different directory for this class under your account.
2. Two different ways exist to do this. In WS_FTP, once you log in to your account, you can create a new directory (a.k.a. “folders”) by pressing a button labeled “Mkdir”, which stands for “Make Directory”. (In Fetch, go to menu “Directories” and choose menu item “Make New Directory…”) You can label the new directory 200a, for example. Within UNIX, you can type mkdir 200a at the Leland server prompt, and that will achieve the same goal.
3. Two different ways exist also for moving your current and future data files. In WS_FTP or Fetch, you can simply drag the data files to your newly created directory. Within UNIX, you can type the following: mv lifeexp.dta 200a/lifeexp.dta The command breaks down as the following: mv stands for “move,” lifeexp.dta is the name of the file you want to move, and 200a/lifeexp.dta is the new directory slash the file name again. You can change the file name if you would like in the new directory, but you have to keep the .dta extension for Stata to recognize it as its data file.
4. From the top level of your Leland account—i.e. what you see when you type ls when you first log in—you can open your new 200a directory by typing cd 200a That stands for “change directory” to 200a. Type ls at that point, and you will see the data files you moved in there.
5. Obviously, if you’d like to create separate folders for each problem set within directory 200a, you can simply repeat steps 2 through 4, giving each directory names like ps1, ps2, etc.
6. Finally, to have Stata be able to access the new data directory, you type the following when you first open Stata and press return: cd 200a Yes, it is the same command as in UNIX. You will see that many of the UNIX commands—such as ls, cd, rm, etc.—work in Stata.