@asinusdk
The fact that (1) you asked for two techniques to solve the problem, and (2) the apparently artificial use of exactly 52 weeks per year, is what made me think of a homework assignment.
However, put that aside. Let me repeat the question @Reeza asked. Is your task of such a nature that exactly 52 weeks/year satisfies what you need to do? Or would you be better off counting, say, the number of Sundays (or Mondays ... Saturdays) in each incoming year? Then you would get a lot of 52 "week" years, and an occasional 53 week year, which would be typical for most "real world data" problems. Once you've answered that, other forum participants can be more helpful to you. Here's a logical data step structure:
data want;
set have;
by id; start=ifn(first.id,0,some_function_of(the_earliest_start)); stop=some_other_function_of(start); if deathm=. then event=0; else event=1; run;
Now once you've confirmed how you want weeks counted, we would know how to replace the italicized expressions above. In fact instead of some_function_of(the_earliest_start), it may be some_function_of(lag(stop)). In your example as you put forth,
start=ifn(first.id,0,lag(stop);
and
stop=start+52;
... View more