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 />
Calculate the adult equivalents<br />
<strong>for</strong> the household<br />
The collapse command<br />
codes are all "average" individuals, and assign them the<br />
adult-equivalent value of .79. (Warning: be very cautious<br />
about "filling in" missing data this way. Careless use of<br />
this technique can give you misleading results. We are<br />
using this example to illustrate the use of Stata commands<br />
and not recommending that you do this routinely to<br />
compensate <strong>for</strong> missing data.)<br />
We will use the Replace command to change the system<br />
missing values (.) in the ae variable to .79.<br />
1. Data then Create or change variables then<br />
Change contents of variable<br />
The replace - Replace into same variable dialog box<br />
will appear.<br />
2. Under the Main tab, select ae in the Variable:<br />
box<br />
3. In the New Contents box type .79<br />
4. Under the if/in tab in the Restrict to<br />
observations if: box type<br />
ae==.<br />
The “period” represents system missing.<br />
5. Don’t <strong>for</strong>get to copy the command into the do-file<br />
editor, then click on the Ok button.<br />
6. Check the results of your replace command by<br />
rerunning the tabulate command.<br />
You should see 9 cases in the frequency with a value of<br />
.79.<br />
The Stata commands are:<br />
replace ae = .79 if ae==.<br />
tabulate ae, missing<br />
Now we need to calculate the number of adult equivalents<br />
<strong>for</strong> each household. The current file is at the member<br />
level, but we need values at the household level. Again<br />
we use Collapse to go from the member level to the<br />
household level. The new variable ae will be calculated<br />
by summing ae across all members of a household.<br />
Reminder: The <strong>Group</strong>ing variable(s) specify the<br />
variables to be used <strong>for</strong> combining cases in the collapsed<br />
file. Any cases from the original file that have identical<br />
values <strong>for</strong> all of the grouping variables will be combined<br />
into a single case in the collapsed file. We want the<br />
collapsed file to have one case per household, so we use<br />
the variables that identify a household in our survey—<br />
district, vil, and hh.<br />
70