The importance of prices, doctor and patient characteristics, and market institutions for the likelihood of choosing generic drugs instead of the more expensive original brand-name version are examined. Using an extensive dataset extracted from The Norwegian Prescription Database containing all prescriptions dispensed to individuals in February 2004 and 2006 on 23 different drugs (chemical substances) in Norway, we find strong evidence for the importance of both doctor and patient characteristics for the choice probabilities. The price difference between brand and generic versions and insurance coverage both affect generic substitution. Moreover, controlling for the retail chain affiliation of the dispensing pharmacy, we find that pharmacies play an important role in promoting generic substitution. In markets with more recent entry of generic drugs, brand-name loyalty proves to be much stronger, giving less explanatory power to our demand model.