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 ...
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 />
<strong>for</strong>each qtr of numlist 1/4 {<br />
local m3 = `qtr'*3<br />
local m2 = (`qtr'*3)-1<br />
local m1 = (`qtr'*3)-2<br />
generate incqtr`qtr' = inc`m1' + inc`m2' + inc`m3'<br />
}<br />
This command computes the quarterly income variables<br />
incqtr1-incqtr4 using the <strong>for</strong>each command.<br />
Display the final output table We can now display a table showing the average caloric<br />
production in quartiles <strong>for</strong> each of the districts.<br />
1. From the menus click on Statistics then<br />
Summaries, tables & tests then Summary and<br />
Descriptive Statistics then Summary statistics<br />
The summarize - Summary statistics dialog box<br />
opens.<br />
2. In the Variable(s): box select cprod_ae.<br />
3. Click on the “by/if/in” tab.<br />
4. Click in the box “Repeat command <strong>for</strong><br />
groups defined by”<br />
5. In the box below this option, select district<br />
quart<br />
6. Click on the copy button, switch to the do-file<br />
editor, paste the command, switch back to the<br />
dialog box and click on Ok.<br />
7. Add a comment to explain what you have done.<br />
The Stata command is:<br />
by district quart sort: summarize cprod_ae<br />
You should note that the mean <strong>for</strong> the 2nd quartile in<br />
Monapo is 2,539.364. The output from the summarize<br />
command gives you the numbers necessary <strong>for</strong> the table.<br />
However the output is difficult to read. There is another<br />
command, table, which can also be used to produce the<br />
final table. We will discuss this command in Section 3.<br />
Be<strong>for</strong>e you save the file, you should sort the file by the<br />
key variables and then save this file as hh-file3,dta.<br />
1. Sort the file by the key variables. Type in the<br />
Command window:<br />
Sort district vil hh<br />
2. We no longer need the variable _merge so it<br />
should be dropped. Type in the Command<br />
80