Hello

So i'm trying to do a lookup in stata but it keeps matching the blanks for some strange reason

i want to create a new variable msk_temp = 1. when any term in the whole of the diagnosis_code column matches the msk_class column, it should assign the temp_msk row as 1

i tried this

foreach x in diagnosis_code{
foreach n in msk_class {
replace temp_msk = 1 if (msk_class == diagnosis_code)
continue, break
}
}

^^ this code only assigns a value of 1 to the diagnosis_codes that are blank


so i would expect row 4 of the temp_msk column to have a 1 in it because contraception appears in the msk_class column


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input strL(diagnosis_code msk_class) float temp_msk
"Depressive disorder"                "Contraception"      0
"Menorrhagia"                        "Foot pain"          0
"Disorder of menstruation"           "Finger injury"      0
"Contraception"                      "Low back pain"      0
"Influenza-like symptoms"            "Plantar fasciitis"  0
"Insomnia"                           "Whiplash injury"    0
"Advice given"                       "Ankle pain"         0
"Prescription requested"             "Shoulder pain"      0
"Posterior rhinorrhoea"              "Anterior knee pain" 0
"Med3 certificate issued to patient" "Chest wall pain"    0
end