That's a little odd since Percocet is mainly used as a pain killer. Benzodiazepines like Xanax are normally used for anxiety.
I think your friend is self-medicating - Percocet is a mix of oxycodone (same as in Oxycontin) and paracetamol (same as in Tylenol). Oxycodone is an opiate and one of the symptoms of withdrawal from an opiate dependency is anxiety, so I think this is what your friend means - if he stops taking the drug he'll feel anxious, so the drug now seems like it's controlling his anxiety (and to some extent it probably is).
The problem is that taking a lot of Tylenol when you don't need it is hard on your liver, and opiates like oxycodone aren't the best or most sustainable way to deal with anxiety anyway. Your friend might have been prescribed Percocet originally for pain relief and become dependent on it, or there might be some other story. If you can carefully bring up the subject you might be able to help your friend get a clearer view of why he's taking it. In the long run he might be better off talking to a doctor and at least switching to a drug designed for anxiety.
Wow. YOu should definitely find your friend some help. Seems like he has created a circular problem. If he stops taking he becomes anxious and so he takes more.
Click Here to search for a treatment center in your state that is right for you.