For one thing, it would be impossible for 1 variable to hold 2 values on a single observation so you would never find an observation where the value for COD was both '21' AND '31'. So I suspect you want to subset those observations where the value for code is either '21' or is '31'.
You could use either of these forms of subsetting IF:
if cod='21' or cod='31';
if cod in ('21', '31');