Announcement

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

  • levelsof Macro Limit: How to Extend?

    I am trying to feed a list of 40000 unique ids to the levelsof macro, my code and returned message are as follows:
    Code:
    levelsof gvkey, local(gv)
    macro length exceeded
    Is there any other way to transer the id list to a macro. Actually I want to estimate the following function
    Code:
    bys loc industry fyear: egen SDm=sd(DPO) if gvkey!=`gv'
    where gv is the name of the local macro
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

  • #2
    Can you explain better what you are trying to do? If your -levelsof- statement had succeeded, the local macro gv would have contained a very long list of values (be they numbers or strings, I don't know). And your subsequent -if gvkey != `gv'- would have thrown a syntax error because you can't just have a long list of things on the right side of an inequality: you must have an evaluable expression.

    So if you can tell us what you were trying to accomplish, maybe we can figure it all out.

    Comment


    • #3
      Thanks Clyde for your reply. Please refer to this post http://www.statalist.org/forums/foru...ing-focal-firm
      I am struggling with calculating standard deviation by year, industry and country, excluding the focal firm (i.e, excluding each firm in front of which the sd is calculated). Though I developed the following code for this purpose which works, but takes years to complete

      Code:
      set more off
      levelsof loc, local(country)
      foreach c of local country{
      levelsof industry if loc=="`c'", local(ind) // loc is string that identifies each country
      foreach i of local ind{
      levelsof gvkey if industry==`i' & loc=="`c'", local(gk)
      foreach g of local gk{
              forval y=1997/2009{
              quietly summarize ROA if gvkey!= `g' & fyear>`y'-1 & fyear<`y'+4 & loc=="`c'" & industry==`i'
              quietly replace SDx= r(sd) if gvkey==`g' & fyear==`y'+4
            }
      }
      }
      }
      Last edited by Attaullah Shah; 29 Sep 2014, 11:45.
      Regards
      --------------------------------------------------
      Attaullah Shah, PhD.
      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
      FinTechProfessor.com
      https://asdocx.com
      Check out my asdoc program, which sends outputs to MS Word.
      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

      Comment


      • #4
        As the original author of levelsof, I am confident that there is a better approach for you if you are pushing at any associated limits.

        See http://www.stata.com/support/faqs/da...ach/index.html Method 1 and come back to us with details if that doesn't appeal as a cleaner approach to your problem.

        Comment

        Working...
        X