Announcement

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

  • looping renaming variables in panel dataset

    Hello, I am curious about how to use "foreach" or "forvalues" command in this situation below:

    gen hlimit1979 = r0144800
    gen hlimit1980 = r0298800
    gen hlimit1981 = r0478100
    gen hlimit1982 = r0776300
    gen hlimit1983 = r1021000
    gen hlimit1984 = r1390300
    gen hlimit1985 = r1773200
    gen hlimit1986 = r2140700
    gen hlimit1987 = r2348500
    gen hlimit1988 = r2710900
    gen hlimit1989 = r2959000
    gen hlimit1990 = r3270400
    gen hlimit1991 = r3557900
    gen hlimit1992 = r3885500
    gen hlimit1993 = r4283900
    gen hlimit1994 = r4961100
    gen hlimit1996 = r5616600
    gen hlimit1998 = r6343600
    gen hlimit2000 = r6887200
    gen hlimit2002 = r7597600
    gen hlimit2004 = r8297400
    gen hlimit2006 = t0895700
    gen hlimit2008 = t2051500
    gen hlimit2010 = t3022800
    gen hlimit2012 = t3953000
    gen hlimit2014 = t4890700
    gen hlimit2016 = t5593800

  • #2
    I have problems following what you want here. First, your title implies a question on rename but you show a list of generate commands. Also, (slightly abusing terminology) while the left-hand-side variable names could easily be put into a fovalues loop running from1979 to 2016, I do not see any obvious pattern on the right-hand-side variables; therefore, I do not see any potential gains from a loop here.

    Best
    Daniel

    Comment


    • #3
      Thanks!

      Comment

      Working...
      X