Hi,
Thank you very much for your reply.
1) Since I will have many other different variables with the same transformation, so it would be great to have a macro to run them all. But datastep or Proc SQL would be OK .
(2)I tried to revised the above example to make it clear.
Account	date	Time	ID	hit
387000	6/10/2010	12:00:00	13.15	1
387000	6/9/2010	12:00:00	13.15	1
387000	6/8/2010	12:00:00	13.14	1
387000	6/6/2010	11:00:00	13.15	1
387000	6/5/2010	10:00:00	13.14	1
387000	6/4/2010	9:00:00	13.13	0
387000	6/4/2010	8:00:00	13.13	0
386000	5/9/2010	10:00:00	12.12	0
386000	5/2/2010	9:00:00	12.14	1
386000	5/1/2010	8:00:00	12.13	0
385000	3/3/2010	10:00:00	11.13	1
385000	3/1/2010	8:00:00	11.12	0
385000	3/1/2010	9:00:00	11.12	0
For example,
(1) For account 387000, since on 06/10/2010, the ID used is 13.15, it is different than the ID of 13.14 used on 06/08/2010 (which is within two days of 06/10/2010), so the hit is 1.
(2) For Account 387000, since on 06/09/2010, the ID used is 13.15, it is different than the ID of 13.14 used on 06/08/2010(which is within two days of 06/09/2010), so the hit is 1.
(3)For Account 387000, since on 06/04/2010 at 9:00am, the ID used is 13.13, within 2 days, the only date is another ID of same 13.13 on 06/04/2010 at time of 8:00am. The hit is 0.
(4)For account 386000, within 2 days of 05/09/2010 would be 05/08/2010 or 05/07/2010. But there is no date likes these two, so the hit is 0.
Thanks again.
Message was edited by: NIU_YA