Announcement

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

  • How can I use the command capture

    Hey, I want to use command capture to gen the variable years for all my databases that dont have it and then to be able to append them

  • #2
    Perhaps this example will start you in a useful direction. I got it by running
    Code:
    help caoture
    and then clicking on the link to the full PDF documentation at the top of the help output and reading the examples.
    Code:
    capture confirm new variable years
    if _rc==0 {
        generate years = 1992
    }
    else {
        display "years already exists on this dataset"
    }
    Last edited by William Lisowski; 02 Oct 2021, 13:58.

    Comment


    • #3
      Optimists might go

      Code:
      capture generate int years = 1992
      as the most likely reason for that to fail (by far) is that years already exists. (The int here shows some care about efficient storage.)

      Comment

      Working...
      X