Announcement

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

  • Determine If Value Is/Is Not Whole Number

    Hi there,

    I have a dataset that contains a field where the values represent the quotient of values from two other fields. Whether or not the value of the quotient is a whole number is important, and I would like to flag those values that are whole numbers, but am not sure how to do that. Below is an example of what I'm trying to do:

    ID quotient flag_wholenumber
    1 2 1
    2 2.533 0
    3 1.5 0

    Any information or advice would be very much appreciated.

    Thanks,
    Erika

  • #2
    my guess is that you want the mod function; e.g.,
    Code:
    gen flag_wholenumber=1 - mod(quotient,1)

    Comment


    • #3
      Another way is:
      Code:
      gen flag_wholenumber = (quotient == int(quotient))

      Comment

      Working...
      X