Answer
Yes — erythromycin 5 mg per gram is exactly the same as 0.5% w/w.
Calculation: 0.5% w/w = 0.5 g per 100 g = 500 mg per 100 g = 5 mg per gram.
Context check: Ophthalmic erythromycin prophylaxis is commonly labeled as 0.5% ointment, which corresponds to 5 mg/g, consistent with guideline notation for neonatal ocular prophylaxis 1.