Announcement

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

  • <istmt>: 3301 subscript invalid r(3301) when rdplot in nested loop

    Hi Community,
    I'm writing a nested Loop with Stata,
    the Variable Cur is a numeric with label, and I want to do rdplot for each Cur,
    with running variable in each of h_pes h_med and h_opt, with any cutoff of 0.1-0.9
    Here's the code:

    forval frx = 1/6{
    preserve
    keep if Cur == `frx'
    local curname: label Cur `frx' // 取回Cur = `frx' 对应的label

    foreach v in h_pes h_med h_opt {

    forval i = 1/9{
    local cut = `i'/10
    local title = "Cur_`curname'_Cutoff_`i'_`v'"
    rdplot exchange `v', c(`cut') ti("`title'") ///
    name(fig`frx', replace)
    }
    }
    restore
    }

    But I get ERROR:
    <istmt>: 3301 subscript invalid
    r(3301);

    Does Anyone has an idea about what's happening?

  • #2
    This thread is about the community-contributed -rdplot- command (see also SJ and SJ).

    I have no idea why this is happening, and it is happening to me too - although not necessarily in a loop and only if I add the
    HTML Code:
    genvars
    option, apparently.

    Let's see if anyone with some knowledge of the package comes to help.

    [Edit] Okay, in my case at least, this was solved by specifying a restriction to exclude missing values of the outcome variable. This is consistent with the error message returned. The command seems to be ill equipped to deal with missing values in at least some instances.
    Last edited by Matteo Pinna Pintor; 07 Dec 2021, 09:56.
    I'm using Stata/MP 17

    Comment


    • #3
      [message included as edit above]
      I'm using Stata/MP 17

      Comment

      Working...
      X