Dear all,
I have two datasets that I would like to merge condition on that the TOM_DATUM fall between startdatum and avslutsdatum. I am not sure how to go about it. I tried with the following code:
use first_dataset, clear
sort lopnr_personid
merge m:1 lopnr_personid using second_dataset, keep if inrange(TOM_DATUM, startdatum, avslutsdatum)
The first_dataset includes
And the second_dataset includes
Thanks,
Tharshini
I have two datasets that I would like to merge condition on that the TOM_DATUM fall between startdatum and avslutsdatum. I am not sure how to go about it. I tried with the following code:
use first_dataset, clear
sort lopnr_personid
merge m:1 lopnr_personid using second_dataset, keep if inrange(TOM_DATUM, startdatum, avslutsdatum)
The first_dataset includes
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long lopnr_personid float(startdatum avslutsdatum) 1 20921 21000 1 20921 21000 1 20921 21000 1 20921 21000 1 20921 21000 1 20921 21000 1 20921 21000 1 20921 21000 1 20921 21000 1 20921 21000 end format %tdCCYYNNDD startdatum format %tdCCYYNNDD avslutsdatum
And the second_dataset includes
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long(lopnr_personid FROM_DATUM TOM_DATUM) 1 16375 16635 1 21915 22645 1 21754 21914 1 20353 21753 1 16801 17166 1 18649 19456 1 12053 14783 1 16017 16374 1 20151 20352 1 17532 17624 end format %tdD_m_Y FROM_DATUM format %tdD_m_Y TOM_DATUM
Tharshini

Comment