Hi all, I have a long dataset with one row for each day an individual participated in a study, and multiple rows for individuals with multiple entry and exit dates, as well as multiple infections with dengue. I want to calculate person-days, but I do not know how to account for individuals who had dengue cases as they should be excluded from contributing person time for one month following illness. I tried this code: %MACRO lag (num); DATA dengue.expand2; set dengue.expand; lag_dengue&num. = lag&num.(resfinaldengue1); if codigo ne lag&num.(codigo) then lag_dengue&num. = .; output; run; %MEND; %lag(1); %lag(2); %lag(3); %lag(4); %lag(5); %lag(6); %lag(7); %lag(8); %lag(9); %lag(10); %lag(11); %lag(12); %lag(13); %lag(14); %lag(15); %lag(16); %lag(17); %lag(18); %lag(19); %lag(20); %lag(21); %lag(22); %lag(23); %lag(24); %lag(25); %lag(26); %lag(27); %lag(28); %lag(29); %lag(30); *Adjusting the number of person-days contributed by codigo based on if they had Dengue; DATA dengue.expand3; set dengue.expand2; if (lag_dengue30='.' AND resfinaldengue1=1) then p_day=0; else p_day = 1; run; Where Codigo= participant id resfinaldengue1= 1 if positive for dengue, 0 if no dengue p_day = person day I also have variables for entry and exit dates, infection start date, and infection start date #2 and #3 if multiple infections. This code made it so that for individuals who did have dengue, the first 30 days under their codigo would be person day = 0. I was wondering if anyone had other suggestions for how to code for this, since this code does not account for individuals who had more than one dengue infection. (I had multiple rows for participants with multiple infections, however, some of those infections occurred within the same entry and exit date).
... View more