04.06.2013 Views

Introduction to Stata 8 - (GRIPS

Introduction to Stata 8 - (GRIPS

Introduction to Stata 8 - (GRIPS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3. Suggested mode of operation<br />

The recommendations in this section only partly follow what is recommended in the [GSW]<br />

manual; I try <strong>to</strong> explain why, when my recommendations differ.<br />

3.1. Issuing commands<br />

The command line window<br />

In the Command line window you may enter commands, one at a time, and execute them.<br />

This works well in simple tasks, but for complex tasks it is a lot safer and more efficient <strong>to</strong><br />

write the commands in a do-file before execution.<br />

The dialogs (menu system) [GSW] 2<br />

The menu system enables you <strong>to</strong> generate quite complex commands without looking them up<br />

in the manuals. You may need <strong>to</strong> do some editing if you are not quite satisfied with the result.<br />

For graphs and many analyses the menus are a blessing. But for documentation commands<br />

(section 9) and calculation commands (section 10) it is a lot easier <strong>to</strong> write the commands<br />

directly in the command window or in a do-file than <strong>to</strong> generate them by the menus.<br />

Do-files [U] 19<br />

See examples of do-files in section 16. A do-file is a series of commands <strong>to</strong> be executed in<br />

sequence. For any major tasks this is preferable <strong>to</strong> entering single commands because:<br />

• You make sure that the commands are executed in the sequence intended.<br />

• If you discover an error you can easily correct it and re-run the do-file.<br />

• The do-file serves as documentation of what you did.<br />

Use the do-file edi<strong>to</strong>r or any text edi<strong>to</strong>r like NoteTab (see appendix 3) <strong>to</strong> enter the commands.<br />

I prefer NoteTab <strong>to</strong> the do-file edi<strong>to</strong>r, because I have direct access <strong>to</strong> several do-files and the<br />

output in one place, although I cannot execute commands directly from NoteTab.<br />

You may, after having issued a number of more or less successful commands, click the upper<br />

left Review window but<strong>to</strong>n <strong>to</strong> save the contents of the Review window as a do-file. The<br />

command log file (cmdlog.txt) may be used for the same purpose.<br />

The do command<br />

Find and execute a do-file by clicking: File ► Do...<br />

or by entering path and filename in the command window:<br />

do c:\dokumenter\proj1\alpha.do<br />

You may also from the do-file edi<strong>to</strong>r execute the entire or a highlighted part of the current file<br />

by clicking the do-but<strong>to</strong>n (number two from the right). The disadvantage of this method is<br />

that the name of your do-file is not reflected in the output. I recommend issuing a do<br />

command with full path and name of the do-file, for reasons of documentation.<br />

7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!