The gauge of your pattern determines which weight of yarn you should select. You can use any yarn that has a suggested gauge equal to the gauge of your pattern.
If you are looking for a particular weight (thickness of yarn) you can shop by weight or click here for additional information.
You can generally substitute one yarn in a weight class for another. For information about substituting specific yarns, click here.
In all cases, be sure to swatch and check your gauge carefully, using whatever size hook or needle is needed to obtain the gauge of the pattern. This method works best if the gauge of your pattern is given over stockinette if knitting, or over single crochet if crocheting. Be sure you are satisfied with the fabric that results; it should be neither too stiff nor too loose. For information on how to make a swatch, click here.
Be aware that if you use a different yarn, your project will not look exactly the same as that pictured with the pattern.