Announcement

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

  • foreach var - problem "ambiguous abbreviation"

    Hi
    I have a panel data set and want to automate the following routine:

    Code:
    replace yr2005 = yr2005*100
    replace yr2006 = yr2006*100
    etc.
    I tried it with
    Code:
    foreach var of varlist y* {
    replace y* = y*/1000000
    }
    However I receive the error "ambiguous abbreviation".

    Please help, thank you.

  • #2
    What you want is
    Code:
    foreach var of varlist y* {
        replace `var' = `var'*100
    }
    By the way, I don't understand why you would divide by 1000000 in your loop to try to replicate a series of multiplications by 100. So I corrected that part, too.

    Comment


    • #3
      Note that if

      Code:
       
       replace y* = y*/1000000
      worked then the rest of the loop would be almost redundant.

      Comment


      • #4
        Thank you for your quick responses. Appreciate your help!
        Best

        Comment

        Working...
        X