![]() |
![]() |
Search DSS Finding Data Using Data About Us DSS lab (Monday-Friday)
![]()
|
Home Introduction to Stata
Stata is a statistical analysis package with programming capabilities. A variety of tasks can be accomplished by issuing commands interactively from the command line. There are commands built into Stata that allow the user to do statistical analysis such as regression on pre-formatted data sets. Stata's commands can also be combined in sequences to solve complex data management and analysis problems. These sequences of commands can be saved in Stata "do files" and run over and over. Issuing CommandsCommands can be executed one at a time at the Stata prompt (command window in Stata for Windows). Just type the command and hit the "Enter" key. Alternatively, groups of commands can be entered into do files which can then be executed. Stata's Online HelpThere is online help available inside Stata. To get help for a command, simply type "help" and the name of the command. If the command exists and you typed in the name correctly then the help screen for that command will display. If you are not sure which command you need, you can type "search" and a keyword. Stata will display a list of commands and other resources associated with that keyword, if there are any. Click on the name of one of the commands or resources to display the help screen. Alternatively, you can use the "Help" menu, and click on "Stata Command" if you know the command or "Search" if you don't. Stata displays information one screen at a time. To proceed to the next screen, hit the space bar or click on the more prompt at the bottom left corner of the results window. If you've seen enough, hit control-k (hold down the control key and type k) on Windows or control-c on Unix to cut off the flow of information. Alternatively, click the break button, which is a red circle with an X through it near the top of the Stata window. Operating System InterfaceStata starts in its default working folder or directory, typically C:\data or C:\stata. If you don't change it to something else, Stata will assume that any file name you type is in the default directory. Since normally your data will be in other directories, you need the cd (Change Directory) command: . cd c:\temp This changes the directory to C:\temp, and until you issue another cd command, Stata will now look for files there. In case you're not sure where you are, you can always find out by giving the pwd (Print Working Directory) command: . pwd Memory requirementsSometimes you may need to allocate additional memory for your Stata session, such as when you are working with a large file. If you recieve this message from Stata when trying to open a data file:
no room to add more observations
then you should increase the amount of
memory available to your Stata session.
Here's how.
How to Reduce Memory RequirementsYou may be able to reduce your memory requirements by saving your data more efficiently. You can use the compress command to reduce the amount of memory your data consumes.
compress
You need to save the new version of the file in order for the changes to remain in effect. Issue the Stata save command followed either by a new name for your Stata file or by the replace operand. For example save myfile2will save a new Stata file named myfile2.dta. You will have the original file, myfile.dta plus the new file. Alternatively, the following command will overwrite the original file: save, replace Keeping Track of Your WorkIt's very important to keep permanent copies of the work you do in Stata. The way to do this is using the log command: . log using 090904.log Once you've issued the log command, from then on everything you type and all the output Stata produces automatically is recorded in the .log file you specify. The .log file saves automatically when you exit Stata. A .log file is a plain text file that you can open and edit in Word, Excel, Notepad, and many other software packages. It is important that you type ".log" at the end of the log command. Do not do this: . log using 090904 If you do, Stata will automatically open a log file called 090904.smcl. The file type ".smcl" is a special Stata format that can only be opened in Stata - not very useful if you want to look at your results. Stata's Built-in Calculator: displayThere is a Stata command called display (abbreviated di) that when used from the command line acts as a built-in calculator: . di (2+2)*5
|