It's clumsy, but it can be done. Here's an approach:
proc sort data=have;
by animal day;
run;
data want;
set have;
by animal day;
array chars {*} _character_;
array nums {*} _numeric_;
output;
prior_day = lag(day);
copy_of_animal = animal;
copy_of_day = day;
call missing (of chars{*});
call missing (of nums{*});
animal = copy_of_animal;
if first.animal and copy_of_day > 1 then do day=1 to copy_of_day-1;
output;
end;
else if copy_of_day > prior_day + 1 then do day=prior_day+1 to copy_of_day-1;
output;
end;
if last.animal and copy_of_day < 100 then do day = copy_of_day + 1 to 100;
output;
end;
drop copy_of_day copy_of_animal prior_day;
run;
You will need to re-sort the observations afterwards.
You said you had 100 days of data per animal, but also said that DAY goes from 0 to 100. Those two are actually slightly different, so I assumed that DAY should go from 1 to 100. Minimal change would be required to go from 0 to 100.
The code is untested, but likely to work as is. It does assume that DAY is numeric. Good luck.
... View more