Announcement

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

  • foreach command may not result from a macro expansion interactively or in do files

    Hallo everyone,

    i want to use command xtpdyn, but i didn't work. So I want to replicate xtpdyn with xtprobit and meprobit. The codes are all in Grotti and Cutuli (2018).

    I use the following codes to capture the initial condition:

    generate sample=!missing(id0, Jahr, Wachstumy_it, Gewerbesaldo, Baugenehmigung, Stadt, West, Schulden )

    . foreach var of varlist Wachstumy_it Gewerbesaldo Baugenehmigung Schulden {
    2. bysort sample id0 (Jahr): generate `var'__0 = `var'[1] if sample & sample[1]==1
    3. }

    but there is an error:
    foreach command may not result from a macro expansion interactively or in do files
    r(198);

    can someone tell me what is wrong with these codes?

    Besides, I dont understand why "bysort sample id0 (Jahr)" instead of "bysort id0 (Jahr)", they should be in this case the same right?
    I also dont unterstand why "sample[1]==1", if i want to use the nonmissing data "sample ==1" should be enough right?

  • #2
    oh i found out that i wont get the error anymore if i delete the red words in do file

    . foreach var of varlist Wachstumy_it Gewerbesaldo Baugenehmigung Schulden {
    2. bysort sample id0 (Jahr): generate `var'__0 = `var'[1] if sample & sample[1]==1
    3. }

    it would be still nice if someone can explain :
    why "bysort sample id0 (Jahr)" instead of "bysort id0 (Jahr)", they should be in this case the same right?
    why "sample[1]==1", if i want to use the nonmissing data "sample ==1" should be enough right?

    Comment


    • #3
      I have almost no idea what you're talking about. Please, provide a data example and your correctly formatted code (using the CODE delimiters). I'm pretty sure nobody could help you in this case without your code, at least, and an example of how your data look.

      Comment

      Working...
      X