This topic, and detailed code review in general, are beyond the purview of IPUMS User Support, so the help I can give is limited, but I’ll share my thoughts since you asked
Your overall approach seems reasonable to me. I assume you’re trying to do this to avoid dropping people who have some data, but not a complete set of longitudinal observations, for example if an individual has data for only 7 of 8 rounds. The one thing that I’ll mention is that I don’t think using an unweighted sample as your starting point is the right way to do the raking. The sampling weights contain important information about the probability of selection into the sample, which will be lost if you start with an unweighted sample. You might consider assigning weights to imputed cases as a first step (for example, assigning the average of an individual’s sampling weights for samples in which they are not missing), and using that as a starting point for the raking process.