I have two tables first one Account consist of following data:
Code | Exposure | Expo_Curr | Limit | Limit_curr | Date_extr
2105 | 2.354586 | EUR | 288.6 | HUF | 1405
2105 | 25.46658 | USD | 12.32 | CAD | 1203
2105 | 5.987456 | CAD | 321.2 | CZK | 1107
2105 | 9.658785 | HRK | 5.365 | EUR | 1103
Second table consist of exchange rate
Code | date_extr | currency_from | currency_to | fx_rate
2105 | 1405 | HUF | EUR | 4.36
2105 | 1203 | USD | EUR | 3.62
2105 | 1203 | CAD | EUR | 1.23
2105 | 1107 | CAD | EUR | 1.17
2105 | 1107 | CZK | EUR | 24.6
2105 | 1103 | HRK | EUR | 35.6
I need to create table where Exposure and Limit will be transferred to EUR currency according to exchange rate in the second table. If the data is already in EUR it should be just multiplied to 1 the rest should be calculated according to rate in second table. The rate should match also the date_extr (YYMM when rate was valid).
Should look like this:
Code | Exposure | Expo_Curr | Limit | Limit_curr | Date_extr
2105 | 2.354586*1.00 | EUR | 288.6*4.36 | HUF | 1405
2105 | 25.46658*3.62 | USD | 12.32*1.23 | CAD | 1203
2105 | 5.987456*1.17 | CAD | 321.2*24.6 | CZK | 1107
2105 | 9.658785*35.6 | HRK | 5.365*1.00 | EUR | 1103
I'm working on SAS, so I tried to do it with SQL join, but I couldn't make it work. If anyone can help to figure out how could I do it? I have more columns to calculate like this.
Thank you in advance.