The chemical reactions and pathways involving any proteoglycan containing heparan sulfate, any member of a group of glycosaminoglycans that have repeat units consisting of alternating alpha-(1->4)-linked hexuronic acid and glucosamine residues, the f.