There are three separated tables. They look like this: table 1: table 2: table 3: subject shot_time subject measurement_a measurement_a_time subject measurement_b measurement_b_time 1 6:35 pm 1 10 6:23 pm 1 20 5:10 pm 1 7:35 pm 1 11 6:24 pm 1 22 5:12 pm 2 5:25 am 1 12 6:23 pm 1 26 5:50 pm 2 7:15 am 1 15 6:23 pm 1 21 6:10 pm 3 3:35 pm 2 9 5:23 pm 1 13 6:30 pm 3 6:15 pm 2 13 6:23 pm 1 22 7:20 pm 3 7:35 pm 2 10 7:23 pm 1 29 8:10 pm I am trying to find the most recent measurement_a and measurement_b from table 2 and table 3 for each shot in table 1. For instance, the first shot for the subject 1 happened in 6:35 pm, then I am trying to get the fourth row in table 2 and fifth row in table 3. And for the second shot of subject 1, I am looking for the fourth row in table 2 and sixth row in table 3. Then I will be able to use some filter to see if each shot is necessary(say measurement_a must be >=12 and measurement_b must be <=30). I have trouble to do that either use proc sql or data step. I am a new SAS user and hope this question won't get too much laugh.... Any input will be appreciated! Thank you!
... View more