i didnt understand meaning of burst ant target flag as johny smith has burst if 3 and total training of 9.5 and it more than burst. Also, event dates for john smith are 12 17 and 21 so difference is more than 7 days so we do not include 12th day into burst? however i will try to write some code example (may contain errors): 1. make data set that contains athletes, types and bursts: data burst; set original; if event_type = 'burst'; week = week('event_date'd, 'v'); /* makes value of which describes which week of the year is it so we can identify if there was enough training that week. you can modify that to other date by playing with sas date statemts */ burst_amount = event_amount; /* make value of needed training per week */ run; 2. make data set without burst and modify with week of the year: data train; set original; if event_type ^= 'burst'; week = week('event_date'd, 'v'); /* makes value of which describes which week of the year is it so we can group training hours by week */ run; 3. sum training hours: proc sql; create table training_total as select name, event_type, week, sum(event_amount) as total_amount from train group by name, event_type, week; quit; 4. get final result: proc sql; create table resuls as select * from ( (select * from burst) s1 left join (select * from training_total) s2 on s1.name = s2.name and s1.event_type = s2.event_type and s1.week = s2.week); quit; data result; set result; if total_amount >= burst_amount than target_flag = 'YES'; else target_flag = 'NO'; keep name event_type week total_amount target_flag; run; im sure there will be mistaces in code as im just puting it right here and havent tested it. is the concept clear to you?
... View more