sas macro - SAS: Keeping observations that have a specified date interval -
i have dataset looks this:
unique_id date 1 03/23/1995 1 03/27/1995 1 04/14/1995 1 08/29/1995 1 02/14/1996 . . . . . . 1 03/19/1997 2 10/20/1993 . . . . . . 2 04/20/2000
within each unique_id need maintain observations have dates @ to the lowest degree 3 months apart starting first observation (my info set sorted unique_id , date). example, within unique_id 1, need maintain next observation @ to the lowest degree 90 days 3/23/1995, next observation 90 days day , on. point me in right direction either macro or kind of loop?
you can seek this:
data want; set have; id; retain date2find; if first.id do; output; /* statement include first obs each */ /* set of ids if desired. if not, delete statement. */ date2find = date + 90; end; if date >= date2find do; output; /* output found record */ date2find = date + 90; /* re-set date found */ end; drop date2find; run;
this relies on dataset beingness sorted described (by id , date)
sas sas-macro
No comments:
Post a Comment