Dear All,

I have a small problem that might be easy to solve but I cannot find a way. Suppose I have the following dataset:


Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float date str32 country long total_cases float monthd
21995 "Afghanistan"             24 722
21996 "Afghanistan"             34 722
21997 "Afghanistan"             40 722
21998 "Afghanistan"             42 722
21999 "Afghanistan"             74 722
22000 "Afghanistan"             80 722
22001 "Afghanistan"             91 722
22002 "Afghanistan"            106 722
22003 "Afghanistan"            114 722
21995 "Albania"                 76 722
21996 "Albania"                 89 722
21997 "Albania"                104 722
21998 "Albania"                123 722
21999 "Albania"                146 722
22000 "Albania"                174 722
22001 "Albania"                186 722
22002 "Albania"                197 722
22003 "Albania"                212 722
21995 "Algeria"                139 722
21996 "Algeria"                201 722
21997 "Algeria"                230 722
21998 "Algeria"                264 722
21999 "Algeria"                302 722
22000 "Algeria"                367 722
22001 "Algeria"                409 722
22002 "Algeria"                454 722
22003 "Algeria"                511 722
21995 "Angola"                   2 722
21996 "Angola"                   2 722
21997 "Angola"                   3 722
21998 "Angola"                   3 722
21999 "Angola"                   3 722
22000 "Angola"                   4 722
22001 "Angola"                   4 722
22002 "Angola"                   5 722
22003 "Angola"                   7 722
21995 "Antigua and Barbuda"      1 722
21996 "Antigua and Barbuda"      1 722
21997 "Antigua and Barbuda"      3 722
21998 "Antigua and Barbuda"      3 722
21999 "Antigua and Barbuda"      3 722
22000 "Antigua and Barbuda"      7 722
22001 "Antigua and Barbuda"      7 722
22002 "Antigua and Barbuda"      7 722
22003 "Antigua and Barbuda"      7 722
21995 "Argentina"              158 722
21996 "Argentina"              266 722
21997 "Argentina"              301 722
21998 "Argentina"              387 722
21999 "Argentina"              387 722
22000 "Argentina"              502 722
22001 "Argentina"              589 722
22002 "Argentina"              690 722
22003 "Argentina"              745 722
21995 "Armenia"                160 722
21996 "Armenia"                194 722
21997 "Armenia"                235 722
21998 "Armenia"                249 722
21999 "Armenia"                265 722
22000 "Armenia"                290 722
22001 "Armenia"                329 722
22002 "Armenia"                407 722
22003 "Armenia"                424 722
21995 "Australia"             1071 722
21996 "Australia"             1549 722
21997 "Australia"             1682 722
21998 "Australia"             2044 722
21999 "Australia"             2364 722
22000 "Australia"             2810 722
22001 "Australia"             3143 722
22002 "Australia"             3640 722
22003 "Australia"             3984 722
21995 "Austria"               2814 722
21996 "Austria"               3582 722
21997 "Austria"               4474 722
21998 "Austria"               5283 722
21999 "Austria"               5588 722
22000 "Austria"               6909 722
22001 "Austria"               7657 722
22002 "Austria"               8271 722
22003 "Austria"               8788 722
end
format %td date
format %tm monthd
Using monthd and country variables, I would like to merge the above dataset with the following:

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str35 country float(monthd temperature)
" Afghanistan"                        722        -.2
" Albania"                            722        2.6
" Algeria"                            722       12.3
" Angola"                             722       22.9
" Antigua and Barbuda"                720       25.7
" Argentina"                          722       21.5
" Armenia"                            722         -7
" Australia"                          722       28.9
" Austria"                            722       -.5
end
format %tm monthd
Obviously the first dataset has a daily frequency, while the second one has a monthly frequency. My idea would be to add the same value of the second dataset to the daily observations in the first one, according to the month. Clearly, for instance for the daily observations in Afghanistan in March, I would like to have the same value (-2) which is contained in the second dataset.

I tried all the possible combinations, using merge, but it seems that none of them works.

Any suggestion?

Thanks