Hi ballardw, Thank you, this was absolutely helpful. Sorry I have not been explicit enough - I am new to this community. I'll try to explain to next steps better: Heart failure (hf_hosp) is only one out of about 40 events that can occur during follow-up, and each event can occur up to 11 times at different timepoints. I am interested in the cumulative cost of each event within specific time periods (90 days, 1 year - 8 years) and subsequently, I want summarize the events' cumulative costs to a total cumulative cost (per patient) within 90 days etc. The coding of the other events is identical to the coding of heart failure. Here's an abbreviated dummy dataset: /*dummy dataset*/
data have;
input ID dis_c_hf_hosp1 dis_c_hf_hosp2 dis_c_hf_hosp3 /*discounted costs for heart failure hospitalization events, no 1-3*/
days_rand2hf_hosp1 days_rand2hf_hosp2 days_rand2hf_hosp3 /*days from randomization to heart failure hospitalizations*/
dis_c_endocarditis1 dis_c_endocarditis2 dis_c_endocarditis3 /*discounted costs for endocarditis events, no 1-3*/
days_rand2endocarditis1 days_rand2endocarditis2 days_rand2endocarditis3 /*days from randomization to endocarditis events*/
dis_c_mi1 dis_c_mi2 dis_c_mi3 /*discounted costs for myocardial infarction events, no 1-3*/
days_rand2mi1 days_rand2mi2 days_rand2mi3 /*days from randomization to myocardial infarction
/*etc*/
;
datalines;
1 8000 7500 7000 60 180 730 28000 27500 27000 50 170 720 18000 17500 17000 70 190 740
2 8500 8000 7000 30 180 730 28000 27500 27000 50 170 720 18000 17500 17000 70 190 740
3 8000 7500 7000 60 180 730 28000 27500 27000 50 170 720 18000 17500 17000 70 190 740
4 9000 8500 7000 10 180 730 28000 27500 27000 50 170 720 18000 17500 17000 70 190 740
5 8000 7500 7000 60 180 730 28000 27500 27000 50 170 720 18000 17500 17000 70 190 740
;
run; With your approach and using a macro, I am able to create a long dataset per event type, but I am not sure how to get from there to getting the cumulative costs per event type and summarize them all. Variables wanted: c90_hf_hosp (cumulative costs of heart failure within 90 days) c1y_hf_hosp c2y_hf_hosp etc... c90_endocarditis (cumulative costs of endocarditis within 90 days) c1y_endocarditis c2y_endocarditis etc... c90_mi (cumulative costs of myocardial infarction within 90 days) c1y_mi c2y_mi etc... c90_all_events (total cumulative costs within 90 days) c1y_all_events c2y_all_events etc... Hope this makes sense and thank you again! Reeza's approach is somewhat similar, but I find the multilabel formats difficult to work with for the subsequent summation, but maybe that's just me!
... View more