Hello everyone,
I am trying to replace values of the variable "NomenCode" based on multiple if statement. This is my data:


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str6 hs6 str2 NomenCode
"030579" "H5"
"030611" "H5"
"030612" "H5"
"030614" "H5"
"030615" "H5"
"030616" "H5"
"030617" "H5"
"030619" "H5"
"030621" "H5"
"030622" "H5"
"030624" "H5"
"030625" "H5"
"030626" "H5"
"030627" "H5"
"030629" "H5"
"030631" "H5"
"030632" "H5"
"030633" "H5"
"030634" "H5"
"030635" "H5"
"030636" "H5"
"030639" "H5"
"030691" "H5"
"030692" "H5"
"030693" "H5"
"030694" "H5"
"030695" "H5"
"030699" "H5"
"030711" "H5"
"030712" "H5"
"030719" "H5"
"030721" "H5"
"030722" "H5"
"030729" "H5"
"030731" "H5"
"030732" "H5"
"030739" "H5"
"030741" "H5"
"030742" "H5"
"030743" "H5"
"030749" "H5"
"030751" "H5"
"030752" "H5"
"030759" "H5"
"030760" "H5"
"030771" "H5"
"030772" "H5"
"030779" "H5"
"030781" "H5"
"030782" "H5"
"030783" "H5"
end
and this is my code and its output:
Code:
. replace NomenCode ="HS4" if inlist(hs6, "030621", "030622", "030624", "030625", "030626", "030627", "030629", "030741") &  NomenCode == "HS5" 
(0 real changes made)
Does anyone know the reason why the code does not change the values in the variable NomenCode even though these values are present in the dataset? Thank you in advance to whoever is willing to help.
Best regards

Alessio Lombini