So you've found a pattern in your great aunt's stash that you just have to knit, but the yarn is no longer available; do not despair, yarn substitution is not as complicated as it may first appear. All you need is a bit of paper and pencil and rudimentary maths!
If you're lucky your pattern should indicate the yardage or meterage per ball of the original yarn. For example, if the original yarn had 100 yards per ball and you require 9 balls to make your chosen size, you'll require 900yds of equivalent yarn. (There is a word of warning here; you should be substituting yarn of equal weight ie. If the pattern calls for double knit you really need to substitute with double knit yarn.)
If you really can not establish the original yarn yardage (a bit of research on the internet can often assist here) the following rough estimate gives a starting point. First you need to work out the wraps-per-inch of your chosen yarn. To do this, wrap the yarn evenly around a ruler (graduated in inches). Do not pull the yarn too tight and make sure the strands lay evenly next to each other.
Count the number of strands over an inch and this will give you the wraps-per-inch (WPI) of the yarn. Multiply the WPI by 100 and this will give you the approximate yardage for a basic, medium adult sweater. If your chosen pattern has any fancy elements (ie. Cables or lace stitches) you will need to buy additional yarn. I would recommend buying a couple of extra knives or balls anyway to be on the safe side, these can always be used to knit scarves, mittens, dolls clothes or be added to you stash for inspiration to strike later!
As always, when you have purchased your yarn, as temptation as it is, do not dive straight in and cast on the back, take the time to do a tension swatch first. Not only will this help you get used to any repeat pattern and decide whether you actually like the pattern / yarn combination but it will ensure that your garment fits after all your hard work.