I have two datasets: one (Dataset1) with the measures start_datetime and end_datetime: start_datetime end_datetime 12345 12349 12355 12370 ... and one (Dataset2) with the measures start_datetime and datetime, which are identical. This one contains all datetimes within the timespan I'm interested in. start_datetime end_datetime 12345 12345 12346 12346 ... I want to merge them on start_time like so: and get datetime start_datetime end_datetime 12344 12345 12349 12345 12345 12349 12346 12345 12349 12347 12345 12349 12348 12345 12349 12349 12345 12349 12350 12355 12370 ... I can then say if datetime >=start_datetime and datetime < end_datetime then indicator=1; else indicator=0; run; However, the merge doesn't work. If I merge on start_time I get datetime start_datetime end_datetime 12344 12345 . 12345 12345 12349 12346 12345 . 12347 12345 . 12348 12345 . 12349 12345 . 12350 12355 . ... This is the same problem described here, but the solution doesn't work. https://communities.sas.com/t5/SAS-Programming/Merging-one-to-many-creates-missing-values/td-p/246022
... View more