Announcement

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

  • Too many variables in loop

    Hello
    I am using the loop function for some simple merges of 5 datasets.
    I did it before and it worked. now to redo it again I faced with" too many variables defined" error. Does anyone help me?
    my syntax is:

    forvalues loop=2002/2016{

    clear

    use "\\...................\F`loop'.dta",

    gen local z=`loop'-1

    merge 1:1 Id using "\\..................\G`z'.dta"

    keep if _merge==3

    drop _merge

    save "\\...........................\Cohort`z'.dta", replace

    }


  • #2
    [CODE]
    gen local z=`loop'-1
    [/CODE

    is wrong. Cut the gen

    Comment


    • #3
      Ahaaa. apparently, someone changed it that is why I did not notice!!! Thanks a lot

      Comment


      • #4
        No idea what that means. Someone else broke your code?

        Comment


        • #5
          Not here! I am working through a shared platform. So it is common to use other codes sometimes. but this time my colleague made some changes and by mistake save on my folder. that is why I said it worked before and now it did not. Thanks for help

          Comment


          • #6
            The code in #1 should never have worked at all.

            Comment

            Working...
            X