Hello!
I have a data set that contrains daily records of milk yields for each individual animal. However, some days are missing in the data (goes from D2-D4 with no D3). I want to fill in these missing days for each individual animal. However, every animal has a different lactation length (ie some go from D1-D400, others from D5-D363). I do have the maximum lactation length as a value in my data set.
Also, once I have filled in all the missing sequence numbers, how do I linearly interpolate the corresponding milk yields for the missing values?
My data looks something like this:
data raw;
input cow_ID day milk_yield max_length
datalines;
1 1 21.6 335
1 2 21.6 335
1 4 21.6 335
...
1 335 16.8 335
3 1 18.4 410
3 3 20.1 410
...
3 410 10.8 410;
run;
So for example, for cow 1 I want to insert a row for her missing day 3 and the linearly interpolate the milk yield for day 3 based on the data from day 2 and day 4.
Thank you in advance