How can I drop observations when a variable is equal to any number from a sequence?

#1
I have a variable in a data set that has numbers between 0 and 1000. I want to drop observations where the variable is equal to any number from the sequence

S=42 + k*12

k=(0,infinity)

Right now the only way I know to do this is by typing out

drop if var == 42 | var == 54 | etc...

for all the numbers in the sequence, which is obviously not the best way to do it.

Could anyone provide help on an efficient way to do this?

Thanks!
 

bukharin

RoboStataRaptor
#2
Re: How can I drop observations when a variable is equal to any number from a sequenc

This may not be the most efficient way but you could try:
Code:
drop if int((var - 42)/12)==(var - 42)/12 & (var - 42)/12>=0
 

Dason

Ambassador to the humans
#3
Re: How can I drop observations when a variable is equal to any number from a sequenc

I don't know stata but it looks like there is a mod function so I think int((var - 42)/12)==(var - 42)/12 could be rewritten as mod(var - 42, 12) == 0 or alternatively mod(var, 12) == 6. The second check could be just written as var >= 42.