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 />

Step 3: Merge the two files<br />

created in steps 1 & 2 to<br />

compute calories produced<br />

per adult equivalent.<br />

The merge command<br />

5. Run the describe command again.<br />

To verify that this variable was created, summarize the<br />

variable ae.<br />

1. Statistics then Summaries, tables and tests<br />

then Summary and Descriptive Statistics then<br />

Summary Statistics<br />

2. Variable is ae<br />

3. Don’t <strong>for</strong>get to copy the command into the do-file<br />

editor, then click on the Ok button.<br />

You should find that the average adult equivalent over all<br />

households is 3.49.<br />

The Stata commands are:<br />

label variable ae "Adult equivalents per household"<br />

summarize ae<br />

This completes step 2. Save this file as HH-FILE2.DTA.<br />

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

2. Filename is hh-file2<br />

3. Click on the Save button.<br />

4. Copy the command from the Results window and<br />

paste it into the do-file editor, delete the reference<br />

to the directory, and add a comment to explain<br />

what you have done.<br />

The Stata command is:<br />

save "hh-file2.dta"<br />

If you run the syntax again and try to save the<br />

“hh-file2.dta”, you will get an error message. To save to<br />

a file that already exists on the hard disk, an additional<br />

subcommand must be added, “, replace”<br />

save "hh-file2.dta", replace<br />

We have created two files: hh-file1.dta, which contains<br />

the calorie-production data <strong>for</strong> all households, and hhfile2.dta,<br />

which contains the adult-equivalent data <strong>for</strong> all<br />

households. We need to combine these files case-by-case<br />

matching by district, village and household, to get both<br />

sets of data into one file. To do this, we use Combine<br />

datasets / Merge two datasets under the Data menu<br />

choice.<br />

72

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

Saved successfully!

Ooh no, something went wrong!