Announcement

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

  • Xlabel: Unrecognized command error

    Hello. I am entering the following code:

    graph twoway (connected index1_w wave if high_vol==0, msymbol(O) mcolor(ananas) msize(large) mlwidth(thick) lcolor(ananas)) ///
    (connected index1_w_mean wave if high_vol==1, msymbol(Oh) mcolor(ananas) msize(large) mlwidth(medthick) lcolor(ananas)) ///
    (rcap high_index1_w_mean low_index1_w wave, lcolor(black)), ///

    xlabel(0 "Baseline" 1 "Endline") xtitle("") ytitle("Average Provider Integration Index Score") legend(order(1 "Non-intervention" 2 "Intervention"))

    My "xlabel" command returns an error: unrecognized command.

    I have searched and looked at the stata guide and cannot spot my error. I would be grateful for any assistance. Thank you.
    Last edited by Kate Sheahan; 05 Oct 2017, 12:07.

  • #2
    Looks as if you have a blank line in there. What's happening is that Stata is thinking that xlabel is a command when to you it's just an option (not a command!). That's happening because Stata thinks your command ends with lcolor(black) and the continuation comment is not linked to anything.

    Happens to me just about every week. I just curse very nicely and edit the code.

    Comment


    • #3
      Thank you for taking the time, Nick. I edited (and cursed) as you suggested:

      graph twoway (connected index1_w wave if high_vol==0, msymbol(O) mcolor(ananas) msize(large) mlwidth(thick) lcolor(ananas)) ///
      (connected index1_w_mean wave if high_vol==1, msymbol(Oh) mcolor(ananas) msize(large) mlwidth(medthick) lcolor(ananas)) ///
      (rcap high_index1_w_mean low_index1_w wave, lcolor(black)), xlabel(0 "Baseline" 1 "Endline") xtitle("") ytitle("Average Provider Integration Index Score") legend(order(1 "Non-intervention" 2 "Intervention"))///

      The first 2 lines run fine, but when I try to run the 3rd line, I get the following error: unrecognized command: ( invalid command name
      When I remove the "(" before rcap, I get an unrecognized command error.

      Would you mind taking a look at this to see if you can spot my error? Thank you again.
      Last edited by Kate Sheahan; 05 Oct 2017, 12:46.

      Comment


      • #4
        Wrong guess. It's not a blank line, I think. I find the ( ) notation to separate commands a real nuisance and always use ||

        If you do that translation I think you get

        Code:
        graph twoway connected index1_w wave if high_vol==0, ///
        msymbol(O) mcolor(ananas) msize(large) mlwidth(thick) lcolor(ananas) ///
        || connected index1_w_mean wave if high_vol==1, msymbol(Oh) mcolor(ananas) msize(large) mlwidth(medthick) lcolor(ananas) ///
        || rcap high_index1_w_mean low_index1_w wave, lcolor(black),  ///
        xlabel(0 "Baseline" 1 "Endline") xtitle("") ytitle("Average Provider Integration Index Score") legend(order(1 "Non-intervention" 2 "Intervention"))
        and then it is easier to see that the comma after lcolor(black) shouldn't be there, which is the problem. Remove it.

        Also, please use CODE delimiters as here and as requested.

        Comment


        • #5
          Thank you, Nick. Unfortunately that did not solve the issue. I still get the error "unrecognized command" even after I amend as you suggest. Baffling. I appreciate your time.

          Comment


          • #6
            I am pretty confident in my diagnosis, but it is hard work to test further without a data example.

            Comment

            Working...
            X