Announcement

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

  • Invalid Syntax Error During Looping

    Hi,

    I am trying to run a non-parametric regression to calculate downward mobility. Whenever I try to run the following command I get an error stating invalid syntax.

    Code:
    forval h=1/`r(max)' {
    forvalues f=90(-10)50 {
    foreach var of varlist child_wage-head_wage {
    qui reg `var' if group==`h' & head_wage>`f'
    outreg2 using "DonwardRankMobility.xls", replace
    }
    }
    }

  • #2
    I would check that r(max) really is there to use at the start of the loop using
    Code:
    return list
    Not the issue, but your regressions are nested. I guess that's deliberate. All they do is produce mean outcomes, which you could also do with summarize.

    Comment


    • #3
      Thank you for this, r(max) was causing the problem but I need to do it for the variable group which takes 8 values.
      The code forval h=1/`1(1)8 does not seem to work.

      Comment


      • #4
        Originally posted by Guest
        Thank you for this, r(max) was causing the problem but I need to do it for the variable group which takes 8 values.
        The code forval h=1/`1(1)8 does not seem to work.
        try with forval h=1/8 instead, it may work
        Last edited by sladmin; 02 Oct 2020, 05:28. Reason: anonymize original poster

        Comment

        Working...
        X