I agree that you should edit your answer to include the now-missing code that it referenced. This ensures that your answer remains comprehensible, which is of course an important goal. :)
I dislike not being able to still give credit to the post that helped me in the first place
It would bother me too.
Here's how I think about it: while I think it's good to preserve a mention of the original authorship, once that person has deleted their answer it's almost as if they never wrote it in the first place. It's kind of hard to plagiarize something that never happened. :)
On the other hand, what if Einstein had somehow gone back in time and destroyed all evidence of his work on relativity? But someone else had seen that work and then used it in their own work. Should that someone else still cite the now-nonexistent work by Einstein? Does the answer depend on whether anyone else in the world also knows it ever happened (e.g. hypothetically let's imagine Einstein also somehow destroyed everyone's memory of his work, except that one someone else…Einstein was just that smart :) )?
Note that on Stack Overflow, once a post is deleted, many users will never see it or know it ever existed.
Me, I think it doesn't hurt to provide the citation and it's intellectually more honest. But once the answer's been deleted, there's no need to mention the answer itself specifically, unless you find that the simplest way to describe the other person's contribution (you could just say "I based this on code I got from user ASh", for example, without a mention of the specific answer).
I also wonder what kind of obligation we have to keep our own answers up-to-date
I think the word "obligation" would be too strong.
I do think that as users, we each are encouraged to do what we can. If we're aware of a need to improve an answer, and we have the time to do so, we should. It's the right thing to do.
But one key feature of the site is that the community has the capability to edit and improve. Fact is, with very few exceptions, there's almost no person contributing to this site that is uniquely qualified to answer any given question. If you could improve the answer, then so could someone else. And if you don't get around to it, probably someone else will. And if they don't, then it might not really have been all that important in the first place.
So, no…I don't think you should feel obligated to go back and improve answers, nor feel badly if you are unable to. It's nice if you do, and there's even a good chance someone will be grateful to you if you do. But there's no obligation per se.