Dear all,

I'm reaching out to you to ask for help with generating a new variable, which is defined by two characterics, from another dataset.

I have two datasets, so this probably needs merging rather than just gen or egen.

I've got a micro dataset with multiple household level variables such as country, gross income, wealth, etc., and I need to create a Net income variable.
Net Income will need to be defined as NI = gross income - incometaxes, where income taxes = taxrate* Gross income.

The issue with this is, that I have the progressive tax rates in another file. On the other dataset I have the countries and their (progressive) tax rates in four groups as a percentage of the average income.

I need to merge the datasets in order, that it would generate an income taxrate to specific household by their country and gross income.
Below an example of the taxrate data. tax67 means an income group where they make 67% of the average income or less, tax100 where they make 68-100% of the average income and so on.

country tax67 tax100 tax133 tax167
AT 0.269 0.324 0.363 0.377
BE 0.333 0.406 0.453 0.483
EE 0.17 0.184 0.191 0.196

All in all, dear Statalist, how to merge the two datasets by country and by gross income? After this I could generate the amount of paid taxes by gross income * taxrate

An example, to make this clear: if a EE household has an monthly income of 2000€'s, and that would be 75% of the average, their merged taxrate would be automaticly 0.184 [67%-100%]. Then I could simply generate the NI as shown above.

I will probably need to:

merge country [something which I haven't figured out] using taxrates, where taxrates is the file with the taxrates.

All the best and thank you in advance,
Antti