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

The key word “unmatched” is used and within<br />

parentheses the type of join is specified). There<br />

are four types of joins:<br />

none - all unmatched observations are ignored<br />

(this is the default), i.e. if there is not a matching<br />

observation in both files, the observation is<br />

dropped from the final dataset.<br />

both - unmatched observations from the “master”<br />

(or file that is in memory) and “using” (file that is<br />

not in memory) data are included.<br />

master - unmatched observations from the<br />

“master” data are included but not unmatched<br />

observations from the “using” file.<br />

using - unmatched observations from the “using”<br />

data are included but not unmatched observations<br />

from the “master” file.<br />

4. Cross datasets. In this type of merge, the first<br />

observation in the first file is joined horizontally<br />

with every observation in the second data set. The<br />

second observation in the first file is then joined<br />

with every observation in the second data set and<br />

so on. This type of file combination is rarely<br />

used.<br />

In this tutorial we will use the “merge” and the “joinby”<br />

commands.<br />

With this in<strong>for</strong>mation in hand, we can now think about<br />

the specific steps we must take to create the file we need<br />

to produce the output we want. Logically, there are three<br />

steps:<br />

1. We need to know how many calories each<br />

household produced <strong>for</strong> the year. We can generate<br />

a file with this in<strong>for</strong>mation using data we have<br />

stored in three files—the production file, c-q4.dta,<br />

and two table-lookup files, conver.dta and<br />

calories.dta.<br />

2. We need to know how many adult equivalents are<br />

in each household. We can generate a file with<br />

this in<strong>for</strong>mation using data from the member file,<br />

c-q1a.dta.<br />

3. We need to combine the results from steps 1 and 2<br />

into one file so we can compute calories produced<br />

per adult equivalent per day.<br />

55

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

Saved successfully!

Ooh no, something went wrong!