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 ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Stata <strong>11</strong> Sample Session Section 2 – Restructuring Data Files – Table Lookup & Aggregation<br />
editor, paste the command, switch back to the<br />
dialog box and click on Ok.<br />
5. Write a comment in the do-file to explain what the<br />
commands are doing.<br />
The number of cases in each cell should be almost the<br />
same counts plus or minus a case or two, e.g.<br />
| district<br />
quart | monapo ribaue angoche | Total<br />
-----------+---------------------------------+----------<br />
1 | 28 30 29 | 87<br />
2 | 27 30 29 | 86<br />
3 | 27 30 29 | 86<br />
4 | 27 29 28 | 84<br />
-----------+---------------------------------+----------<br />
Total | 109 <strong>11</strong>9 <strong>11</strong>5 | 343<br />
Examples of the <strong>for</strong>each looping<br />
command<br />
The new variable requires a label:<br />
1. Click on Data, then Data utilities, then Label<br />
utilities, then Label variable.<br />
2. In the Variables: box, select the name of the first<br />
variable: quart<br />
3. In the Attach label to variable (up to 80<br />
characters) box, type<br />
Calorie production quartile<br />
4. 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 />
The Stata command is:<br />
label variable quart "Calorie production quartile"<br />
Examples of the use of the <strong>for</strong>each command are:<br />
Computing new variables:<br />
<strong>for</strong>each var of varlist inc1-inc12 {<br />
generate tax`var' = `var' * .10<br />
}<br />
Collapsing across variables:<br />
79