Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to drop the values of a variable that are equal to the multiples of 3 (3, 6, 9, 12, etc)?

    Hi! How can I drop the values of a variable that are equal to the multiples of 3 (3, 6, 9, 12, etc)?
    Thank you!

  • #2
    the mod() function is your friend here; since there is no data example, I make up variable names:
    Code:
    drop if mod(var1,3)==0
    
    or, if you want to keep a record
    
    gen byte wanted=mod(var1,3)
    drop if wanted==0

    Comment


    • #3
      Thank you Rich! It help me =)

      Comment


      • #4
        Code:
        keep if mod(var1, 3)
        is for those who like a small challenge.

        Comment

        Working...
        X