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 />
Converting continuous variables to<br />
indicator variables<br />
the values in indicator variables are 0 and 1 or no/yes.<br />
Examples of indicator variables are:<br />
Is a person a citizen of the U.S.? (no/yes).<br />
Does a farmer use fertilizer? (no/yes).<br />
Stata can convert continuous variables to categorical and<br />
indicator variables and it can also convert categorical variables to<br />
indicator variables.<br />
Suppose we want to create a new variable that indicates whether<br />
a person is 18 years old or older. You could have generated a<br />
new variable and assigned it a value of 1 if ca3 > =18. Then you<br />
would need a second step to recode the system missing to 0.<br />
There is another way to create this variable.<br />
We will use the file c_q1a.dta. Open the file and then create a<br />
new variable using the generate command following the steps<br />
below:<br />
1. Click on File then Open .<br />
2. Select c_q1a.dta and click on Open. Copy the<br />
command to the do-file editor. Delete the reference to<br />
the directory.<br />
3. Check to see if there are any missing values in the age<br />
variable - ca3. Use the list command<br />
list if ca3 >=.<br />
We are checking to see if there are missing values<br />
because Stata considers missing values to be<br />
greater than any number.<br />
4. Select Create or change variables from the Data<br />
menu<br />
5. Select Create new variable<br />
The generate - Generate a new variable dialog box<br />
opens.<br />
6. Under the Main tab, type the name of the new<br />
variable in the Generate Variable box: age18p<br />
7. For the Contents box, type in<br />
ca3>=18<br />
8. Click on the Generate variable as type drop down<br />
box and change to byte.<br />
9. 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 />
10. Run a tabulate to look at the results.<br />
Note: if there had been a missing value <strong>for</strong> an<br />
observation, that observation would have been<br />
assigned a value of 1.<br />
It would have been better to put a qualifier on the command<br />
to assign the values to cases where ca3 was not missing<br />
(e.g. ca3 < .).<br />
100