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

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

prod unit conver<br />

(Product) (unit) (conversion factor)<br />

... ... ...<br />

7 8 19<br />

7 24 53<br />

... ... ...<br />

30 8 17<br />

30 24 47<br />

... ... ...<br />

• calories.dta: This also is a table-lookup file, created<br />

<strong>for</strong> convert kilograms of food into calories of food. It<br />

contains two variables:<br />

a. prod - the product (crop)<br />

b. calories - number of calories per kilogram of<br />

each of the crops<br />

To create a data files that will produce the output table<br />

described above, we need to combine the data from different<br />

files. There are different methods that can be used to combine<br />

files, depending on what is desired. In Stata, we can<br />

1. Append datasets. Appending data sets means that<br />

the data in different files have the same variables<br />

and the desire is to add one data set of<br />

observations to the end of another data set (or<br />

append one file to the end of another file). An<br />

example would be that you entered data <strong>for</strong><br />

harvest in one file <strong>for</strong> one district and entered data<br />

<strong>for</strong> harvest <strong>for</strong> another district into another file.<br />

We want the data to be in the same file. To do<br />

that, we would use the append command.<br />

2. Merge datasets. Merge combines datasets<br />

horizontally matching corresponding observations.<br />

An example is a survey asking questions about the<br />

household in Part 1 and another set of questions<br />

about the household in Part 3. Each part of the<br />

survey is entered into a different data file. To<br />

combine Part 1 and Part 3 (where both sets of data<br />

are at the household level), we would use the<br />

merge command.<br />

3. Joinby datasets. This type of merge combines<br />

datasets horizontally matching all pairwise<br />

combinations possible. An example is a set of<br />

data on parents and a set of data on children.<br />

Joinby would match the parents to every<br />

observation of the children within that family.<br />

54

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

Saved successfully!

Ooh no, something went wrong!