10.04.2013 Views

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 ...

SHOW MORE
SHOW LESS

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 />

to select it again from the menus.<br />

5. In the Variable: box, select the name of the<br />

second variable: cprod_tt<br />

6. In the New variable label (map be up to 80<br />

characters) box, type<br />

Total calories produced<br />

7. 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 the Ok button.<br />

8. Add a comment to the do-file to explain what<br />

you have done.<br />

The Stata commands are:<br />

label variable qprod_tt "Total production in kgs"<br />

label variable cprod_tt "Total calories produced"<br />

This gives us a new working data file with total calories<br />

produced per product <strong>for</strong> each household.<br />

Select only staple food products The final output table asks only <strong>for</strong> in<strong>for</strong>mation about the<br />

staple food crops. These are defined as:<br />

peanuts (prod=5))<br />

rice (prod=6)<br />

nhemba bean (prod=30)<br />

manteiga bean (prod=31)<br />

manioc (prod=41)<br />

sorghum (prod=44)<br />

maize (prod=47)<br />

We can find the product code by looking at prod in the<br />

questionnaire. Since we are only interested in those<br />

products, we need to exclude the rest of the cases about<br />

other crops. Stata uses the “keep” command. Once you<br />

run this command you will no longer have the complete<br />

data set available. You must remember that you should<br />

never save a file to the same name after you have selected<br />

out a set of data. You will overwrite the original data and<br />

no longer have the complete set.<br />

The keep if command To select just a subset of cases:<br />

1. Click on Data, then Create or change<br />

variables, then Keep or drop observations.<br />

You should see the drop - keep or drop<br />

observations dialog box.<br />

2. Under the Main tab select the round button next<br />

to Keep Observations<br />

3. In the Observations to keep if: box type<br />

prod == 5 | prod == 6 | prod == 30 |<br />

prod == 31 | prod == 41 | prod ==44 |<br />

prod == 47<br />

63

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!