The downward trend for retail pharmacies is due in part to rising costs and shifts in consumers' shopping habits.