Announcement

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

  • Variable looping

    Cheers, Here is the code that I have

    Code:
    gen date1990 = amo + ayear
    gen date1992 = bmo + byear
    gen date1994 = cmo + cyear
    and so on through date2014. I am wondering if this is loopable?

  • #2
    Code:
    tokenize "`c(alpha)'" 
    
    forval y = 1/13 { 
        local Y = 1988 + 2 * `y'
        gen date`Y' = ``y''mo + ``y''year
    }
    Some of the small arithmetic behind that -- working out that there are 13 instances -- should have been in the question.

    Comment

    Working...
    X