I am currently working on a datasets that consists of customer booking information across different airlines all over the world. Among many others, my dataset includes the following variables:
Type of airline (number), Continent of country of origin, Date, Booking price, etc. Each row is a specific booking of a passenger to that a booking with American Airlines on the 15th of July might look like the following: 8416, North America, 07/15/19, 149
I now want to add another variable to my initial dataset that devides my observation into further subgroups. This new variable shall depent on the observations across the first two variables as describes above. For this purpose, I have created an additional dataset that looks like the folowing:
4589, North America, subgroup1
3542, North America, subgroup1
8943, North America, subgroup1
4589, South America, subgroup1
3542, South America, subgroup1
8943, South America, subgroup1
etc.
I now want Stata to merge the new third variable (subgroup) into the old dataset, filtered by the first two variables. In that sense: Each row that contains an observation included in one of the first two variables (Type & Continent) shall now be given the additional variable (subgroup). Type Codes might fluctuate across Continents in the sense that the same code applies to two different Continents. The newly created subgroup may only added if both the observations of variable one and two match the ones as created in my additional dataset.
I hope this makes sense to you.
I am trying to figue a way for quite some time now. I am experimenting with the various options of merge. However, I can't seem to force my conditions on the merge.
Maybe someone can help; many thanks in advance

0 Response to Merging new variable conditioned on two other observations
Post a Comment