Hi all,
I'm having a bit of difficulty getting the AND/OR commands to work.
The problem that I have is that the coding is shared across all variables (it's a set of product codes), but I want to link it to the original variable specified in that line of code. I've added part of the code below, and all of the codes (code1/2/3/4) are being linked with both product 1 and 2 - even though 1/2 are only mentioned alongside product1 (and the same problem with product2). How can I prevent this?
Thanks,
Calum
gen newvar=0
replace newvar=1 if product=="product1" & productcode=="code1" | lsoanum=="code2"
replace newvar=1 if product=="product2" & productcode=="code3" | lsoanum=="code4"
I'm having a bit of difficulty getting the AND/OR commands to work.
The problem that I have is that the coding is shared across all variables (it's a set of product codes), but I want to link it to the original variable specified in that line of code. I've added part of the code below, and all of the codes (code1/2/3/4) are being linked with both product 1 and 2 - even though 1/2 are only mentioned alongside product1 (and the same problem with product2). How can I prevent this?
Thanks,
Calum
gen newvar=0
replace newvar=1 if product=="product1" & productcode=="code1" | lsoanum=="code2"
replace newvar=1 if product=="product2" & productcode=="code3" | lsoanum=="code4"
Comment