<Download and Open files on Stata>

 

*** To print this page, click here. (two-page MS Word format)

 

1. Getting Ready!

 

Programs you need: 1) Stata, 2) WS_FTP (File Transfer Protocol for PC. Download at http://www.stanford.edu/dept/itss/ess/pc/pc.html and install in your computer. You may want to reboot after each installation), and 3) ‘WinZip’(demo version)or ‘Aladdin Expander’ (free)(Unzip the file into *.dta when you downloaded a compressed file.) 

 

2. How to download data file?

 

Click the <file name> on the homework site, and store it anywhere you can remember (you can try at our website; look for a ‘riot.dta’ and download it to your computer). For more information, go to ‘downloading data files to your computer’ at Moonhawk’s manual.

 

3.How to transfer the downloaded file to my home directory, so that I don’t have to carry my diskette all the time?

 

Once you downloaded the file, run WS_ FTP, and type in the commands as following;

 

(file name) a (or it can be any other)

(Host Name/Address)transfer.stanford.edu

(Host Type) Automatic Detect

SUNet ID and Password

à    (Start Up/ Initial Remote Site Folder) /afs/ir/users/(first character of SUNet ID)/(second character)/(SUNet ID) 

à    Click ‘OK’ 

à     

Q.What if my home directory become full…..?

 

You can also create another directory on your account. On WS_FTP, click ‘Mkdir’ and enter any name for the folder, such as ‘PS 100A’. The new directory will have a path like /afs/ir/users/s/t/statman/PS 100a (If your SUNet ID is ‘statman’). Moonhawk also shows how to do it on Mac or Unix. (Refer to ‘managing the data files’ at Moonhawk’s manual. )

 

4. How to open a data file on Stata?

 

use " D:\Winter 2001\PS 312\corruption.dta", clear 

 

: Be sure to enter USE, instead of OPEN or something. There is no such command like that… In addition, don’t forget to put your directory within the quotation marks. Without it, Stata won’t be able to recognize where to get the fileOr, simply just click ‘open’ icon and designate the path (Right. It is much easier).

 

Q. Why enter“, clear” at the last part? 

 

: clear permits the data to be loaded even if there is a dataset already in memory and even if that data has changed since it was last saved (copied from Stata Help). In short, it orders the previous data set you were running to be automatically stored and safely closed. (Clear = store + close)

 

Q. What if the file is not *.dta but *.zip? 

 

: Run ‘WinZip’ or ‘Aladdin Expander’ to unzip the file à Save the *.dta file to the place that you can remember à Designate this place to open the file. For expanding files on Unix or Mac, refer to ‘Using the Data Files’ on Moonhawk’s manual

 

Q. Stata says ‘”no room to add more observations’’. What should I do? 

 

set mem(ory) 20000

: Your PC allocates default amount of memory (not sure how much) for Stata to do its job. However, if a data set is larger than Stata can handle with its allocated memory, you need to assign more memory to Stata. ( If you want to know how to change the default amount, you can visit here, though I would prefer not to change the default setting.) In case of dytch.dta, the size of the file is 7.38MB, where as the size of, say, mcDs.dta is6.21KB (1000KB = 1MB). Obviously, dytch.dta seems to be quite big for Stata (at least, Stata keeps saying that it cannot load the observations), and we need to set more memory. Stata.com, in this context, provides two useful advices. 

“Make sure you allocate an amount of memory that is larger than the file that you are using. If your file is 30 megabytes, you may want to allocate 50 megabytes of memory to Stata. Stata will need the extra room to perform any commands or calculations. A good rule of thumb for large files is to allocate roughly 50% more memory then the size of your file. If you are using smaller files (< 2megabytes), then allocating 5 Megabytes on a PC with 64 Megabytes of RAM is a good general guideline. 

(Also) Make sure that you do not allocate too much memory, because your computer will not have enough memory (RAM) left to perform other tasks. For example, if you only have 64 megabytes of RAM, then you should not allocate more than that. If you have a file that is larger then the amount of RAM installed on your computer, you will have to acquire more memory, work on a more powerful computer, or sacrifice speed by using virtual memory. See http://www.stata.com/support/faqs/data/large.html for more information about virtual memory and Stata. “

We simply put ‘20000’ because we want to be less bothered by the above conditions each time we load different data sets.…In fact, 20000 works fairly well in most cases that you will meet throughout the PS 100A/200A. If you want brain exercises, however, you are welcome to set other amount of memory that fits better (ex. in case of dytch, 7.38 + (7.38 x .5) => about 12 MB ? ). 


 

ftp: file transfer protocol that is used to transfer files between computers. (protocol : a standard procedure for regulating data transmission between computers)

WS_FTP: a file transfer application that is used to transfer files between your local PC and a remote FTP server.

Home directory: Any UNIX system can have many users on it at any one time. As a user you are given a home directory in which you are placed whenever you log on to the system. User's home directories are usually grouped together under a system directory, such as /home.For example, our class website directory is, /afs/ir/class/polisci100a. Your home directory is, if your SUNet ID is Statman, /afs/ir/users/s/t/statman. 

Using ftp on UNIX

Go to http://cyclone.stanford.edu/software/ftp/sample-ftp.html

 

For more questions, please contact jakim@stanford