Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: cmissing for xtline


From   Carlos Eduardo Hernandez Castillo <[email protected]>
To   <[email protected]>
Subject   st: cmissing for xtline
Date   Mon, 26 May 2008 02:06:34 -0500

Dear all,


I have a panel data base, where the ID variable is "city" and the time variable is "year". I have information of "est_sal_nat" for 1996, 1999, 2001 and 2006; and I would like to plot a "xtline est_sal_nat, overlay" graph. However, data before 1999 is not comparable with data after 2001. Therefore, I would like a break in 2000. I reckon that, if I were using something like a twoway plot, I may create new obs filled with missings and then use the cmissing(no) option (http://www.stata.com/statalist/archive/2006-11/msg00882.html). However, this option is not available for xtline. Therefore, this is what I get:

. xtset city year
       panel variable:  city (strongly balanced)
        time variable:  year, 1996 to 2006, but with gaps
                delta:  1 unit
. set obs 20
obs was 16, now 20
. replace year=2000 in 17/20
(4 real changes made)
. replace city=_n-16 in 17/20
(4 real changes made)
. xtline  est_sal_nat, overlay cmissing(n)
option cmissing() not allowed


So I had to create artificial cities:

. replace city=city+4 if anno>2000
(8 real changes made)
. xtline  est_sal_nat, overlay


But then I had to take care of fixing the lines and the legend of the plot:

. xtline est_sal_nat, overlay scheme(s2mono) plot1opts(lpattern(solid)) plot5opts(lpattern(solid)) plot2opts(lpattern(dash)) plot6opts(lpattern(dash)) plot3opts(lpattern(shortdash)) plot7opts(lpattern(shortdash))  plot4opts(lpattern(longdash_dot)) plot8opts(lpattern(longdash_dot)) legend(order(1 2 3 4) rows(1))



Which is ok for 4 cities and a break, but would not be ok for more cities or breaks; especially while working with loops. 

Can you imagine an easier way?
Is there a reason for not allowing cmissing with xtline?

Thanks in advance for your help.

Carlos Eduardo Hernandez
Colombia



_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index