Announcement

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

  • Converting values of a variable from units to millions

    Dear all,

    I have two variables on the amount of foreign aid. One is in millions and the other one in units.

    I want to make their units same. More specifically, Is there any code through which I can permanently convert the values in units to millions?

    I will then be taking their logs to be used as final variables.


    Looking forward to your response.

    Best regards,
    Imran Khan.

  • #2
    I would typically leave the original data untouched and create a new variable.

    Code:
    gen double y2  = y / 1000000
    or

    Code:
    gen double y2 = y / 1e6
    is how to divide by 1 million. Check out

    Code:
    help operators
    for operators that should be familiar and for operators that you don't yet know. I used dopey variable names above, as you don't tell us what yours are. .

    Comment


    • #3
      Many thanks Nick.

      It did the job.

      Best regards,
      Imran Khan.

      Comment

      Working...
      X