10.04.2013 Views

STATA 11 for Windows SAMPLE SESSION - Food Security Group ...

STATA 11 for Windows SAMPLE SESSION - Food Security Group ...

STATA 11 for Windows SAMPLE SESSION - Food Security Group ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Stata <strong>11</strong> Sample Session Section 2 – Restructuring Data Files – Table Lookup & Aggregation<br />

Document the do-file with<br />

comments<br />

window:<br />

drop _merge<br />

3. Click on File/Save As...<br />

4. Filename is hh-file3<br />

5. Click on Save.<br />

6. Copy the three commands and paste them into the<br />

do-file.<br />

7. Close the log file. Type in the Command<br />

window<br />

8. Copy this command into the do-file.<br />

Remember to save the contents of the Do-file Editor to a<br />

permanent file so you can use it another time.<br />

1. The Do-File Editor should be the active window<br />

2. Click on File/Save As...<br />

3. Use the filename session2<br />

The .do extension will be added automatically.<br />

This file now contains all the commands that you pasted<br />

either from the Command window or from the Review<br />

window or from dialog boxes.<br />

Note: Whenever you do any substantial amount of work,<br />

you should always copy the commands to a do-file and<br />

save the file so that you have documentation on what<br />

analysis you have done and so you can repeat the<br />

analysis without building all the commands again.<br />

Documenting the do-file with comments can save you<br />

much time trying to remember what analysis you did and<br />

why.<br />

Let's see how you would retrieve the do-file you just<br />

created. To exit Stata<br />

1. Click on File then Exit<br />

Stata will prompt you if you have not saved the<br />

data file and will give you an opportunity to<br />

return to the program to save the data file.<br />

If you do not want to save your data file,<br />

click on “yes” to exit.<br />

Start Stata again. To open our do-file:<br />

1. Click on Window then Do-file editor then New<br />

Do-file or press or you can click on the<br />

Do-file editor icon on the tool bar.<br />

81<br />

log close

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

Saved successfully!

Ooh no, something went wrong!