Announcement

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

  • local numlist not working for mkspline

    Hi all,

    I am using mkspline to create manually chosen knots for analysis. However, I got an error message if I ran the following code:

    Code:
    cap drop ppcusp*
    _pctile earnings, nq(100)
    foreach a in 1 5 10 25  50 75 90 95 99 {
        local knlist "`knlist'  " "  r(r`a')"
    }
    disp `knlist'    // this gives 120.95 793.51001 1783.34 4546.29 8707.8604 14286.59 21961.449 29073.65 57494.488
    mkspline ppcusp = wpcaqe, cubic knots(`knlist') displayknots
    knots() invalid -- invalid numlist
    r(121);
    However, if I ran the following code, it works...
    Code:
    mkspline ppcusp = wpcaqe, cubic knots (120.95 793.51001 1783.34 4546.29 8707.8604 14286.59 21961.449 29073.65 57494.488) displayknots
    I really hope the approach with locals can work so that I will not need to manually copy and paste the values.

    Any suggestions to fix the code will be highly appreciated!

    Best,
    Long
    Last edited by Long Hong; 06 Jun 2024, 15:15.

  • #2
    EDITED: Consider

    Code:
    local numlist "1 3 5"
    di `numlist'
    di `"`numlist'"'
    Res.:

    Code:
    . local numlist "1 3 5"
    
    . 
    . di `numlist'
    135
    
    . 
    . di `"`numlist'"'
    1 3 5
    Last edited by Andrew Musau; 06 Jun 2024, 15:53.

    Comment


    • #3
      Thanks, Andrew Musau!

      It does not solve the issue. The issue comes from the numlist for knot of -mkspline-, but not the numlist for -foreach-

      Comment


      • #4
        I noticed that. See my edit.

        Comment

        Working...
        X