Announcement

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

  • r(100) error

    Hi everyone

    While running the code to plot a twoway graph, I am getting the following r(100) error- ) required.
    I understand this could be something to do with incomplete parenthesis but I not quite able to figure out the exact error.

    The following is the code I'm trying to use:
    twoway (connected avg_treatment Year, legend(label(1 "avg_treatment") size(small) cols(3)))(connected avg_control Year, legend(label(2 "avg_control"))), xtitle("Year") ytitle("CO2emissions") xlabel(2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019) graphregion(margin(vlarge) color(gs16)), xline(2016.5, lpattern(dash))

    I would be super grateful to have this solved.

    Thank you very much in anticipation.



  • #2
    I think the problem is the comma that appears before xline. It should not be there. In Stata commands, there is a single comma that separates the beginning of the command from the options. But commas are not used to separate options. Additional commas may appear within some options to set off sub-options, such as the one within your -xline()- option. But having a comma between two options is not allowed.

    Comment


    • #3
      Thank you for your response.

      I tried doing that but the error still remains.

      Comment


      • #4
        I don't know what to tell you. When I remove the comma and run the command (kludging some data from auto.dta to give it something to work with) it runs without error messages:

        Code:
        . sysuse auto, clear
        (1978 automobile data)
        
        .
        . rename trunk avg_treatment
        
        . rename headroom avg_control
        
        . rename price Year
        
        .
        . twoway (connected avg_treatment Year, legend(label(1 "avg_treatment") size(small) cols(3)))(connected avg_control Year, legend(label(2 "
        > avg_control"))), xtitle("Year") ytitle("CO2emissions") xlabel(2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019
        > ) graphregion(margin(vlarge) color(gs16)) xline(2016.5, lpattern(dash))
        
        .
        end of do-file

        Comment


        • #5
          Thank you for your response.

          I'll restart Stata, try running the entire code once again and check.

          Comment


          • #6
            It does work now!
            Thank you very much

            Comment

            Working...
            X