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 3 – Tables and other Types of Analysis<br />
The count command<br />
The recode command<br />
The egen command<br />
To answer this question you can count the number of times the<br />
value of 1 appears in the variable associated with maize. To<br />
count the number of times a value appears in the variable. The<br />
command is count<br />
count if h64a == 1<br />
In the Results window you see the value of 86. You could also<br />
run a frequencies:<br />
tabulate h64a<br />
The tabulate shows that 147 did not increase sales of maize as<br />
well as 86 households who did. Now we change the question.<br />
B. How many crops increased in sales within the household?<br />
For this question we can sum the number of 1's in the variables<br />
associated with this question using the egen command. We<br />
need to recode the value of 2 to 0.<br />
Recode:<br />
1. Select Create or change variables from the Data<br />
menu<br />
2. Select Other variable trans<strong>for</strong>mation commands<br />
then Recode categorical variable<br />
The recode - Recode categorical variable dialog<br />
box opens.<br />
3. Under the Main tab, click in the Variables box and<br />
select all the variables that start with h64, e.g. h64a<br />
h64b h64c h64d h64e h64f h64g h64h<br />
4. In the box <strong>for</strong> Required: type<br />
(2=0)<br />
3. Click on the copy button, switch to the do-file editor,<br />
paste the command, switch back to the dialog box and<br />
click on Ok.<br />
The Stata command is:<br />
recode h64a h64b h64c h64d h64e h64f h64g h64h (2=0)<br />
The values in the h64x variables are either 0=no or 1=yes. We<br />
are ready to count the number of crops that increased in sales:<br />
1. Select Create or change variables from the Data<br />
menu<br />
2. Select Create new variable (extended)<br />
The egen - Extensions to generate dialog box<br />
opens.<br />
3. Under the Main tab, type the name of the new variable in<br />
the Generate Variable box: ncrops<br />
95