Announcement

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

  • ) required

    Hello, I am writing a code to plot a difference in differences, I have the following:

    twoway (scatter price_index Year if Treatment == 1, msymbol(O) mcolor(blue)) ////
    (scatter price_index Year if Treatment == 0, msymbol(O) mcolor(red)) ////
    legend(label(1 "Treatment") label(2 "Control")) ///
    ytitle("Price index") xtitle("Year") ///
    vertical(2021, lpattern(dash)) ///
    title("Price Index Chart by Treatment")

    But when I run the code I get the error ") required". Honestly, I can't see where I'm missing the ")". I would really appreciate your help.

    Regards.


  • #2
    The error message you got is misleading. There is nothing wrong with your parentheses. The problem is that the material on the third line and beyond is all options, and therefore, there needs to be a comma before they begin. So put a comma at the end of the second line and this problem goes away.

    It then surfaces another problem. The line -vertical(2021, lpattern(dash))- is wrong. There is no -vertical()- option in -graph twoway-. I don't know what you intended here, so I can't offer a fix (other than just leaving it out altogether.)

    Putting that altogether
    Code:
    twoway (scatter price_index Year if Treatment == 1, msymbol(O) mcolor(blue)) ////
    (scatter price_index Year if Treatment == 0, msymbol(O) mcolor(red)), ////
    legend(label(1 "Treatment") label(2 "Control")) ///
    ytitle("Price index") xtitle("Year") ///
    title("Price Index Chart by Treatment")
    will produce your graph, except for whatever you were looking for when you put in that non-existent -vertical()- option.

    Comment


    • #3
      It is a matter of taste as well as experience but I've never been attracted to the () syntax for combining twoway commands. I always use ||. There are enough parentheses already to keep track of.

      Comment

      Working...
      X