Dear All,
I have a panel of 50 US states. I want to plot twoway graphs by state with 2 xlines corresponding to state-specific policy dates.
In 7 states one of the policies was not implemented and datesah==. Similarly, datebr is missing for one state in which the second policy was not implemented. I use the following code:
local l1=datesah
local l2=datebr
# delimit ;
twoway
(line employed date if year>2018, by(state, legend(off))
mcolor(dkgreen) lwidth(medium) lcolor(gs8) msize(small)),
xline(`l1' , lwidth(1.2) lcolor(cranberry) lpattern(solid))
xline(`l2', lwidth(1.2) lcolor(gs10) lpattern(dash))
xtitle("") ytitle("`T'", size(vsmall))
xlabel(, valuelabel labsize(vsmall)) legend(off) legend(size(small))
ylabel(/*-.3(.1).10*/, labsize(small) )
graphregion(color(white))
graphregion(margin(r+5))
bgcolor(white)
name(`T', replace)
;
However, even in the states in which the datesah==., an xline is drawn! Will be grateful for any help in identifying the error in the code please.
Sincerely,
Sumedha.
I have a panel of 50 US states. I want to plot twoway graphs by state with 2 xlines corresponding to state-specific policy dates.
Code:
Code:* Example generated by -dataex-. To install: ssc install dataex clear input str2 state float(date datesah datebr employed) "AK" 660 722 722 .6134562 "AK" 661 722 722 .6062745 "AK" 662 722 722 .6099811 "AK" 663 722 722 .6096507 "AK" 664 722 722 .6186984 "AK" 665 722 722 .58469224 "AK" 666 722 722 .59321356 "AK" 667 722 722 .6300213 "AK" 668 722 722 .6272353 "AK" 669 722 722 .6030574 "AK" 670 722 722 .6014582 "AK" 671 722 722 .6003797 "AK" 672 722 722 .5942172 "AK" 673 722 722 .6026699 "AK" 674 722 722 .582865 "AK" 675 722 722 .5996858 "AK" 676 722 722 .6078303 "AK" 677 722 722 .5827603 "AK" 678 722 722 .59311074 "AK" 679 722 722 .6154088 "AK" 680 722 722 .6148482 "AK" 681 722 722 .6029711 "AK" 682 722 722 .6113046 "AK" 683 722 722 .6175244 "AK" 684 722 722 .6149542 "AK" 685 722 722 .6408562 "AK" 686 722 722 .5977551 "AK" 687 722 722 .619123 "AK" 688 722 722 .6132277 "AK" 689 722 722 .5903868 "AK" 690 722 722 .6014633 "AK" 691 722 722 .5907012 "AK" 692 722 722 .5994622 "AK" 693 722 722 .6166711 "AK" 694 722 722 .6114097 "AK" 695 722 722 .59366053 "AK" 696 722 722 .5762024 "AK" 697 722 722 .58752257 "AK" 698 722 722 .5800669 "AK" 699 722 722 .57041144 "AK" 700 722 722 .5892659 "AK" 701 722 722 .5911551 "AK" 702 722 722 .5901152 "AK" 703 722 722 .6098812 "AK" 704 722 722 .6314541 "AK" 705 722 722 .611174 "AK" 706 722 722 .5903183 "AK" 707 722 722 .55938345 "AK" 708 722 722 .5303159 "AK" 709 722 722 .5876039 "AK" 710 722 722 .55010223 "AK" 711 722 722 .5615274 "AK" 712 722 722 .5751279 "AK" 713 722 722 .5789146 "AK" 714 722 722 .58060056 "AK" 715 722 722 .5864722 "AK" 716 722 722 .594985 "AK" 717 722 722 .58575314 "AK" 718 722 722 .5617474 "AK" 719 722 722 .578275 "AK" 720 722 722 .5774603 "AK" 721 722 722 .58465946 "AK" 722 722 722 .5511447 "AK" 723 722 722 .50068116 "AL" 660 723 722 .53064406 "AL" 661 723 722 .5327162 "AL" 662 723 722 .5383225 "AL" 663 723 722 .56434226 "AL" 664 723 722 .55375487 "AL" 665 723 722 .5283147 "AL" 666 723 722 .5284564 "AL" 667 723 722 .53293097 "AL" 668 723 722 .54089206 "AL" 669 723 722 .5442664 "AL" 670 723 722 .53669107 "AL" 671 723 722 .53187686 "AL" 672 723 722 .5313467 "AL" 673 723 722 .5314885 "AL" 674 723 722 .53691477 "AL" 675 723 722 .5409332 "AL" 676 723 722 .5463466 "AL" 677 723 722 .53984725 "AL" 678 723 722 .5206069 "AL" 679 723 722 .5357757 "AL" 680 723 722 .5326864 "AL" 681 723 722 .5405985 "AL" 682 723 722 .53849167 "AL" 683 723 722 .51547205 "AL" 684 723 722 .52882457 "AL" 685 723 722 .5507693 "AL" 686 723 722 .5439147 "AL" 687 723 722 .5490048 "AL" 688 723 722 .5393151 "AL" 689 723 722 .5323984 "AL" 690 723 722 .5234152 "AL" 691 723 722 .5445439 "AL" 692 723 722 .56595045 "AL" 693 723 722 .55801505 "AL" 694 723 722 .5553959 "AL" 695 723 722 .54677755 end format %tm date format %tm datesah format %tm datebr
In 7 states one of the policies was not implemented and datesah==. Similarly, datebr is missing for one state in which the second policy was not implemented. I use the following code:
local l1=datesah
local l2=datebr
# delimit ;
twoway
(line employed date if year>2018, by(state, legend(off))
mcolor(dkgreen) lwidth(medium) lcolor(gs8) msize(small)),
xline(`l1' , lwidth(1.2) lcolor(cranberry) lpattern(solid))
xline(`l2', lwidth(1.2) lcolor(gs10) lpattern(dash))
xtitle("") ytitle("`T'", size(vsmall))
xlabel(, valuelabel labsize(vsmall)) legend(off) legend(size(small))
ylabel(/*-.3(.1).10*/, labsize(small) )
graphregion(color(white))
graphregion(margin(r+5))
bgcolor(white)
name(`T', replace)
;
However, even in the states in which the datesah==., an xline is drawn! Will be grateful for any help in identifying the error in the code please.
Sincerely,
Sumedha.
Comment