Announcement

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

  • Display results of a loop

    Hi everyone,

    I'm trying to perform a Fisher-type test based on augmented Dickey-Fuller tests with 0 lags on several variables stored in a macro variable: local vars LCO2 LP LGDP LR LN LIND LS LU LPD LGDP2 LU2 LEI.

    The problem is that when I run the following loop, Stata doesn't display any results:

    foreach var of local vars {
    xtunitroot fisher `var', dfuller lags(0)
    }

    Do you have any suggestions?
    Thanks

  • #2
    Strictly speaking, your local macro (which is not itself a kind of variable) should contain the names of the variables. The variables themselves are stored in the dataset.

    That's pedantry, if you like.

    The explanation for your problem of no results is naturally more important.

    My guess is that you are running commands one by one from a do-file editor OR that you defined the local macro in one place and are trying to access it in another place. One place might be your interactive session (what is based on commands typed in the command window) and another place might be a do-file or the contents of a do-file editor window.

    More at https://journals.sagepub.com/doi/pdf...36867X20931028 where these problems are discussed.

    The code should work, I think, if (but only if) you run it all interactively or you run all those commands together at once.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      Strictly speaking, your local macro (which is not itself a kind of variable) should contain the names of the variables. The variables themselves are stored in the dataset.

      That's pedantry, if you like.

      The explanation for your problem of no results is naturally more important.

      My guess is that you are running commands one by one from a do-file editor OR that you defined the local macro in one place and are trying to access it in another place. One place might be your interactive session (what is based on commands typed in the command window) and another place might be a do-file or the contents of a do-file editor window.

      More at https://journals.sagepub.com/doi/pdf...36867X20931028 where these problems are discussed.

      The code should work, I think, if (but only if) you run it all interactively or you run all those commands together at once.
      It works, thank you very much.
      Last edited by anna mantelli; 17 Jun 2024, 05:18.

      Comment

      Working...
      X