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 />
Create a variable with the adult<br />
equivalent <strong>for</strong> each person<br />
The generate.... if command<br />
The replace.... if command<br />
this survey are:<br />
Males, 10 years and older = 1.0<br />
Females, 10 to 19 years old = 0.84<br />
Females, 20 years and older = 0.72<br />
Children, under 10 years old = 0.60<br />
We will use the Generate.../If... command to compute<br />
the adult equivalents <strong>for</strong> each member. We will name the<br />
adult equivalent variable that we create as ae.<br />
1. Select Create or change variables from the<br />
Data menu<br />
2. Select Create new variable<br />
The generate - Generate a new variable dialog box<br />
opens.<br />
3. Under the Main tab, type the name of the new<br />
variable in the Generate Variable box:<br />
ae<br />
4. For the Contents box, type the value of 1<br />
5. Click on the if/in tab.<br />
6. Type the statement ca4 == 1 & ca3 >= 10<br />
7. Click on OK<br />
Now that the new variable has been created, another<br />
command is used to assign the codes <strong>for</strong> the other adult<br />
equivalent groups that have not yet received a value. We<br />
use the replace command.<br />
8. Select Create or change variables from Data<br />
9. Select Change contents of variable.<br />
The replace-Replace contents of variables dialog box<br />
opens.<br />
10. In the Variables box select the name of the<br />
variable that was just created: ae<br />
<strong>11</strong>. Type .84 in the New Contents box<br />
12. Click on the If/In tab.<br />
13. In the Restrict to observations if box, type in<br />
ca4==2 & (ca3 >=10 & ca3 =20<br />
16. Click on the Main tab.<br />
17. Type .72 in the Contents box .<br />
18. Click on Submit. The dialog box remains open<br />
and the command is run.<br />
19. Type .6 in the Contents box<br />
20. Click on the If/In tab.<br />
21. In the Restrict to observations if box, change<br />
the criteria to: ca3