Below we load fh2017.dta and look at the first five rows in the dataset, with the help of the command list. We now have two datasets, fh2017.dta and cpi2018.dta. Then we get information about corruption from Transparency International, and treat it the same way. The data is in Excel format, but we can just cut the relevant parts and paste into a Stata dataset. We can get information about democracy from Freedom House. Let's say we want to combine information about the level of democracy in a country with the level of corrption in the country. We start with the simplest type: when we have the same type of observations in both datasets, and want to add mode variables. Combine two datasets with the same type of observations - merge 1:1 ¶ It is the exact same thing, but instead of starting with the individual level dataset, we start with the country level dataset, and add the individual level data. In our individual level dataset we can have thousands of observations, and still combine it with about 30 country-level observations (one for each country). All persons in Norway will also have the same value - Norway is not a member of the EU. All persons in Sweden will have the same value - Sweden is a part of the EU. Imagine that we have conducted a survey, and now want to see whether the answers are affected by whether the country of residence is an EU member or not. For instance, we might have data on persons in Europe, and want to add country-level information. It means that we have many observations in the dataset that is active in Stata, and want to add on data from a smaller number of observations, at a higher level. We then need a matching variable, a key, that shows the country's or the person's identity, so we can match the information in the two datasets.īut we can also match m:1. ![]() For instance the same individuals, or the same countries we just want to add more information about them. ![]() It means that we have the same observations in both datasets. With the merge command we can do three (or really, two) different types of merges. ![]() But since merge is a bit trickier we will focus on that command in this guide. In those cases, we use the command append, which really is the same as pasting more observations to the dataset. We do this with the command merge.Īnother scenario is when we have different datasets with the same variables, but with different units of analysis. We thus have the same observations in both datasets, but want to combine the variables. We might get information about the independent variable from one source, and want to analyze the effects of it on a dependent variable from another source. Many statistical analyses requires the that we comvbine several datasets.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |