Announcement

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

  • How to substract two variables

    Hi everyone, I just want to know how to substract two variables. This what I mean:

    n_iden rest
    12 10
    12 10
    12 10
    12 10
    12 10
    12 10

    I want to susbtract 12 from 10 and generate a new variable. I dont how, any help would be appreciated. Thanks
    Last edited by Ndm Sanchez; 04 May 2019, 21:32.

  • #2
    Well, to just directly answer your question
    Code:
    gen difference = rest - n_iden
    But if this is something you are unfamiliar with, you need to stop whatever you are doing and learn the basics of Stata before going on. You will make very little progress on any problem if nearly every line of Stata code you need requires you to post a question and wait for a response from a Forum like this.

    I think the best advice for complete Stata beginners comes from William Lisowski, in post #5 at https://www.statalist.org/forums/for...uplicate-dates. I strongly recommend you read that and follow the advice given there.

    Comment


    • #3
      Thank you so much Clyde, I did it with that code yesterday but it did not work. I dont know hoy but today it run perfectly. So, again, thank you so much for the advice and answer.

      Comment

      Working...
      X