Thank you, this works well and it's efficient. I should have, however, specified a bit further, since what I also need is a NEW variable that counts the occurrence of multiple colors. See below variable called REDANDBLUE. Of course, i could calculate it in a further step, as a sum of NEWRED and NEWBLUE, but I wonder whether it could be done in one step. I tried NEWRED=count(var,'red' 'blue') and I have tried NEWRED=count(var,'red', 'blue'), but neither works. Again, sorry for not posting the whole thing at once. e OBS VAR NEWRED NEWBLUE NEWYELLOW REDANDBLUE 1 red blue red red blue yellow 3 2 1 5 2 red 1 0 0 1 3 blue yellow 0 1 1 1
... View more