Announcement

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

  • Correcting variable to 1 decimal point

    I have two datafiles and I am trying to merge them using an identification variable called HHID. In the first file the identification variable HHID is saved as double %8.0g .
    When I try to merge these two files several of the observations are not merged despite the identification variable HHID having the same value.
    When I check in the browser window i notice that in the first file all values of the identifier variable HHID are rounded up to one decimal point. However, in my second file the identification variable HHID is rounded up to one decimal point but it is 'saved' as up to 10 decimal points. For example, a value of HHID shows as 3.1 but it is saved as 3.0999999943.
    This may be the reason I am not able to merge many observations in my data files.

    I would appreciate any suggestion on how to converting the HHID variable into 1 decimal point to merge my data.

  • #2
    Code:
    help precision

    Comment


    • #3
      As a heheh comment about ID variables, I maintain that for identification variables, these are best stored as either integer-valued (in Stata this could be int or long) or strings, depending on their source. Forcing them to decimal numbers, such as here, not only can cause issues of precision but also avoids the erroneous use of encode which occasionally crops up here.

      Comment


      • #4
        Silly autocorrect. That should start “As a general comment…”

        Comment

        Working...
        X