Announcement

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

  • invalid 'replace'

    So I am almost finished with my research between Premiership Parties and Governing Parties without Premiership, and at my final command I get an error message called "invalid 'replace' "

    use MPDataset_MPDS2017b_stata14, clear
    gen ptype = 0
    replace ptype = 0 if party == 11320 | party == 11420 ///
    | party == 11620 | party == 11810 | party == 13320 | party == 13410 ///
    | party == 13420 | party == 13620 | party == 14320 | party == 14620 ///
    | party == 14810 | party == 21320 | party == 21322 | party == 21421 ///
    | party == 21422 | party == 21423 | party == 21425 | party == 21426 ///
    | party == 21521 | party == 22320 | party == 22521 | party == 22522 ///
    | party == 22722 | party == 23420 | party == 23520 | party == 33210 ///
    | party == 33610 | party == 34020 | party == 34212 | party == 34313 ///
    | party == 34511 | party == 35311 | party == 35313 | party == 35520 ///
    | party == 41320 | party == 41521 | party == 42320 | party == 42520 ///
    | party == 51320 | party == 51620 | party == 53520 | party == 53620 ///
    replace ptype = 1 if party == 11110 | party == 11520 ///
    | party == 13001 | party == 13230 | party == 14110 | party == 14222 ///
    | party == 14223 | party == 14520 | party == 14820 | party == 14901 ///
    | party == 21111 | party == 21112 | party == 21321 | party == 21522 ///
    | party == 21913 | party == 21916 | party == 22330 | party == 22526 ///
    | party == 22528 | party == 23113 | party == 23320 | party == 34213 ///
    | party == 34710 | party == 34730 | party == 41111 | party == 41112 ///
    | party == 41113 | party == 41420 | party == 42420 | party == 42710 ///
    | party == 51420 | party == 51421 | party == 53110 | party == 53320 ///
    label variable ptype "party type"
    label define ptype 0 "Premiership Parties" 1 "Governing Non-Premiership Parties"
    label values ptype ptype

    here, the "replace" is 'invalid'.

    However, the following command I did earlier works without any problems:

    keep if date > 194000
    twoway (scatter niche57 herfinN if party == 11320 | party == 11420 ///
    | party == 11620 | party == 11810 | party == 13320 | party == 13410 ///
    | party == 13420 | party == 13620 | party == 14320 | party == 14620 ///
    | party == 14810 | party == 21320 | party == 21322 | party == 21421 ///
    | party == 21422 | party == 21423 | party == 21425 | party == 21426 ///
    | party == 21521 | party == 22320 | party == 22521 | party == 22522 ///
    | party == 22722 | party == 23420 | party == 23520 | party == 33210 ///
    | party == 33610 | party == 34020 | party == 34212 | party == 34313 ///
    | party == 34511 | party == 35311 | party == 35313 | party == 35520 ///
    | party == 41320 | party == 41521 | party == 42320 | party == 42520 ///
    | party == 51320 | party == 51620 | party == 53520 | party == 53620, ///
    msymbol(circle)) ///
    (scatter niche57 herfinN if party == 11110 | party == 11520 | ///
    party == 13001 | party == 13230 | party == 14110 | party == 14222 ///
    | party == 14223 | party == 14520 | party == 14820 | party == 14901 ///
    | party == 21111 | party == 21112 | party == 21321 | party == 21522 ///
    | party == 21913 | party == 21916 | party == 22330 | party == 22526 ///
    | party == 22528 | party == 23113 | party == 23320 | party == 34213 ///
    | party == 34710 | party == 34730 | party == 41111 | party == 41112 ///
    | party == 41113 | party == 41420 | party == 42420 | party == 42710 ///
    | party == 51420 | party == 51421 | party == 53110 | party == 53320, ///
    msymbol(X)), ///
    title("Nicheness/Concentration") ///
    subtitle("Premiership Parties vs Governing Non-Premiership Parties") ///
    legend(label(1 "PP") label(2 "GNPP"))


  • #2
    For starters, you have an incorrect line continuation "///" on the line before "replace ptype = 1 if party == 11110 | party == 11520 ..."

    Comment


    • #3
      Originally posted by Mike Lacy View Post
      For starters, you have an incorrect line continuation "///" on the line before "replace ptype = 1 if party == 11110 | party == 11520 ..."
      I added that one later and just removed it again. The error message stays unaffected, the replace is still invalid.

      Comment


      • #4
        Originally posted by Mike Lacy View Post
        For starters, you have an incorrect line continuation "///" on the line before "replace ptype = 1 if party == 11110 | party == 11520 ..."
        Thank you Mike. I just realized i also had a wrong continuation line before "label variable ptype "party type". Aswell with your hint, those were the errors.

        Comment

        Working...
        X