I have been using the syntax format below to replace the data in the columns with the relevant med_costs which has worked for 4 sets of columns. When I run the code for the eczema related column data with the costs listed in the med_costs column the below syntax isn't working.

gen Eczema_related=.
replace Eczema_related=med_costs if med_name_group=="Eczema_related"

Do you have any suggestions of how to fix this?