Dear colleagues ,
I forgot to write in my last post that I wanted to replace the first observation of s1 with spn_serotype if s1 is 1 but combining with Q. I dont want to do this directly like replace s1="Q1" if spn_serotype=="13" since I have several s in my full data i.e s1 to s67 whose value 1 correspond to different spn_serotypes and so I want a code which I can generalize using foreach loop easily. It is not working for me.see my code and data below. Kindly assist
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 15 out of 15 observations
. replace s1="Q"+spn_serotype if s1=="1" in 1
(0 real changes made)
Regards,
Fred Orwa
I forgot to write in my last post that I wanted to replace the first observation of s1 with spn_serotype if s1 is 1 but combining with Q. I dont want to do this directly like replace s1="Q1" if spn_serotype=="13" since I have several s in my full data i.e s1 to s67 whose value 1 correspond to different spn_serotypes and so I want a code which I can generalize using foreach loop easily. It is not working for me.see my code and data below. Kindly assist
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str11(spn_serotype s1) "13" "0" "15B" "0" "35B" "0" "8" "0" "35B" "0" "19F" "0" "21" "0" "29" "0" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" end
Listed 15 out of 15 observations
. replace s1="Q"+spn_serotype if s1=="1" in 1
(0 real changes made)
Regards,
Fred Orwa
Comment