Announcement

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

  • parentheses do not balance

    Hello, I am trying to do a graph with confidence intervals. I got the following code:

    twoway (rcap low high fecha if Tratamiento == 1 & No_Paga_IVA == 0) ///
    (rcap low high fecha if Tratamiento == 0 & No_Paga_IVA == 0), ///
    (line log_precios fecha if Tratamiento == 1 & No_Paga_IVA == 0, ///
    lcolor(blue) lwidth(medthick) lpattern(solid)) ///
    (line log_precios fecha if Tratamiento == 0 & No_Paga_IVA == 0, ///
    lcolor(red) lwidth(medthick) lpattern(solid)), ///
    xline(date("Jan-2021", "DMY"), lpattern(dash) lcolor(cranberry)) ///
    xtitle("Fecha") ytitle("log(precios)") ///
    legend(order(1 "Tratamiento=1, No_Paga_IVA=0" 2 "Tratamiento=0, No_Paga_IVA=0")) ///
    title("Gráfico de log(precios) por Fecha")

    but i get the "parentheses do not balance" and honestly i do not know where am i missing o lacking a parentheses.

    I will really appreciate your help.

  • #2
    You have a comma at the end of the second line which should be removed.

    (rcap low high fecha if Tratamiento == 0 & No_Paga_IVA == 0), ///
    Also this won't work:

    xline(date("Jan-2021", "DMY"),
    [.] You may try:

    Code:
    xline(`=date("01-Jan-2021", "DMY")',

    Comment


    • #3
      It's a matter of taste but mine is never to use () whenever I can use || to indicate different twoway calls -- for the reason biting here, that there are so many parentheses to keep track of

      Code:
      local when = mdy(1,1,2021) 
      
      twoway rcap low high fecha if Tratamiento == 1 & No_Paga_IVA == 0 ///
      || rcap low high fecha if Tratamiento == 0 & No_Paga_IVA == 0  ///
      || line log_precios fecha if Tratamiento == 1 & No_Paga_IVA == 0, ///
      lcolor(blue) lwidth(medthick) lpattern(solid) ///
      || line log_precios fecha if Tratamiento == 0 & No_Paga_IVA == 0, ///
      lcolor(red) lwidth(medthick) lpattern(solid) ///
      xline(`when', lpattern(dash) lcolor(cranberry)) ///
      xtitle("Fecha") ytitle("log(precios)") ///
      legend(order(1 "Tratamiento=1, No_Paga_IVA=0" 2 "Tratamiento=0, No_Paga_IVA=0")) ///
      title("Gráfico de log(precios) por Fecha")
      I can't test this, but there are some tiny tips there.

      Comment

      Working...
      X