Patients who try to save money by getting generic prescriptions for creams and ointments to treat skin conditions like eczema and psoriasis may face sticker shock at the pharmacy, a U.S. study suggests.

Researchers compared the average co-payments, or out-of-pocket prices, for several commonly prescribed topical corticosteroids, which have been used for decades to treat a wide range of inflammatory skin conditions.

Out-of-pocket prices varied wildly depending on the container size, researchers found. Co-payments were also three to five times higher for name-brand generics than for no-name versions of the same drugs.

With so many factors influencing costs, patients may only get the lowest price if they consider co-payments long before they get to the pharmacy, said Dr. Charles Ellis, a professor of dermatology at the University of Michigan Health System in Ann Arbor.

"It's best to talk with the doctor in the office about the price," Ellis, who wasn't involved in the study, said by email.

Prescription medications accounted for about $307 billion, or 12 percent, of all U.S. health spending as of 2010, Dr. Joslyn Kirby of Penn State Milton Hershey Medical Center and colleagues note in their study published in JAMA Dermatology.

In theory, generic drugs are supposed to come on the market after brand-name versions lose U.S. patent protection and help lower prices by increasing competition. The reality, however, is much messier.

Kirby and colleagues offer just one example of this Byzantine market with their study of topical corticosteroid prices.

They compared average co-payments and wholesale prices of the medicines based on the potency, or how much medication is blended into the ointments or creams, as well as whether the drugs were brand-name generics or no-name generics.

For many products, researchers also calculated prices per gram based on tube sizes ranging from 15 grams to 80 grams, as well as for one medicine sold in a 454-gram container.

In one case, they found that no-name triamcinolone acetonide, a medium-strength corticosteroid, cost 24 cents per gram in a 15-gram tube but just 2 cents a gram in the 454-gram container.

But in another case, they found that no-name hydrocortisone acetate, a low-potency option, cost 15 cents per gram for either a 15-gram or a 60-gram tube.

Because pharmacists aren't allowed to swap one corticosteroid for another unless both products contain the same medication in the same potency and the same type of cream or ointment, patients may not be able to easily switch to a cheaper alternative at the drugstore, said Dr. Aaron Kesselheim, a pharmaceutical researcher at Harvard Medical School and Brigham and Women's Hospital in Boston.

"There is unfortunately no good way, other than working with your pharmacist to identify a low-cost alternative and then having the pharmacist call the physician to obtain a new prescription," Kesselheim, who wasn't involved in the study, said by email.