I want to create a bar graph that compares change in the outcome variable at the level of county versus state by the rank variable
pre_rateq and pre_rateq_s respectively
. Both
pre_rateq and pre_rateq_s take the values 1-4 and reflect quartiles.
My data is an annual panel as follows:Code:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte state int county float(year pre_rateq pre_rateq_s avgdeloxy_mme_pc avgdeloxy_mme_pc_s) 1 1 2006 3 3 -.01886584 -.033673316 1 1 2007 3 3 -.01886584 -.033673316 1 1 2008 3 3 -.01886584 -.033673316 1 1 2009 3 3 -.01886584 -.033673316 1 1 2010 3 3 -.01886584 -.033673316 1 1 2011 3 3 -.01886584 -.033673316 1 1 2012 3 3 -.01886584 -.033673316 1 1 2013 3 3 -.01886584 -.033673316 1 1 2014 3 3 -.01886584 -.033673316 1 1 2015 3 3 -.01886584 -.033673316 1 1 2016 3 3 -.01886584 -.033673316 1 1 2017 3 3 -.01886584 -.033673316 1 3 2006 4 3 -.0551143 -.033673316 1 3 2007 4 3 -.0551143 -.033673316 1 3 2008 4 3 -.0551143 -.033673316 1 3 2009 4 3 -.0551143 -.033673316 1 3 2010 4 3 -.0551143 -.033673316 1 3 2011 4 3 -.0551143 -.033673316 1 3 2012 4 3 -.0551143 -.033673316 1 3 2013 4 3 -.0551143 -.033673316 1 3 2014 4 3 -.0551143 -.033673316 1 3 2015 4 3 -.0551143 -.033673316 1 3 2016 4 3 -.0551143 -.033673316 1 3 2017 4 3 -.0551143 -.033673316 1 5 2006 2 3 -.007270626 -.033673316 1 5 2007 2 3 -.007270626 -.033673316 1 5 2008 2 3 -.007270626 -.033673316 1 5 2009 2 3 -.007270626 -.033673316 1 5 2010 2 3 -.007270626 -.033673316 1 5 2011 2 3 -.007270626 -.033673316 1 5 2012 2 3 -.007270626 -.033673316 1 5 2013 2 3 -.007270626 -.033673316 1 5 2014 2 3 -.007270626 -.033673316 1 5 2015 2 3 -.007270626 -.033673316 1 5 2016 2 3 -.007270626 -.033673316 1 5 2017 2 3 -.007270626 -.033673316 1 7 2006 4 3 -.0551143 -.033673316 1 7 2007 4 3 -.0551143 -.033673316 1 7 2008 4 3 -.0551143 -.033673316 1 7 2009 4 3 -.0551143 -.033673316 1 7 2010 4 3 -.0551143 -.033673316 1 7 2011 4 3 -.0551143 -.033673316 1 7 2012 4 3 -.0551143 -.033673316 1 7 2013 4 3 -.0551143 -.033673316 1 7 2014 4 3 -.0551143 -.033673316 1 7 2015 4 3 -.0551143 -.033673316 1 7 2016 4 3 -.0551143 -.033673316 1 7 2017 4 3 -.0551143 -.033673316 1 9 2006 3 3 -.01886584 -.033673316 1 9 2007 3 3 -.01886584 -.033673316 1 9 2008 3 3 -.01886584 -.033673316 1 9 2009 3 3 -.01886584 -.033673316 1 9 2010 3 3 -.01886584 -.033673316 1 9 2011 3 3 -.01886584 -.033673316 1 9 2012 3 3 -.01886584 -.033673316 1 9 2013 3 3 -.01886584 -.033673316 1 9 2014 3 3 -.01886584 -.033673316 1 9 2015 3 3 -.01886584 -.033673316 1 9 2016 3 3 -.01886584 -.033673316 1 9 2017 3 3 -.01886584 -.033673316 1 11 2006 1 3 -.0007063786 -.033673316 1 11 2007 1 3 -.0007063786 -.033673316 1 11 2008 1 3 -.0007063786 -.033673316 1 11 2009 1 3 -.0007063786 -.033673316 1 11 2010 1 3 -.0007063786 -.033673316 1 11 2011 1 3 -.0007063786 -.033673316 1 11 2012 1 3 -.0007063786 -.033673316 1 11 2013 1 3 -.0007063786 -.033673316 1 11 2014 1 3 -.0007063786 -.033673316 1 11 2015 1 3 -.0007063786 -.033673316 1 11 2016 1 3 -.0007063786 -.033673316 1 11 2017 1 3 -.0007063786 -.033673316 1 13 2006 2 3 -.007270626 -.033673316 1 13 2007 2 3 -.007270626 -.033673316 1 13 2008 2 3 -.007270626 -.033673316 1 13 2009 2 3 -.007270626 -.033673316 1 13 2010 2 3 -.007270626 -.033673316 1 13 2011 2 3 -.007270626 -.033673316 1 13 2012 2 3 -.007270626 -.033673316 1 13 2013 2 3 -.007270626 -.033673316 1 13 2014 2 3 -.007270626 -.033673316 1 13 2015 2 3 -.007270626 -.033673316 1 13 2016 2 3 -.007270626 -.033673316 1 13 2017 2 3 -.007270626 -.033673316 1 15 2006 4 3 -.0551143 -.033673316 1 15 2007 4 3 -.0551143 -.033673316 1 15 2008 4 3 -.0551143 -.033673316 1 15 2009 4 3 -.0551143 -.033673316 1 15 2010 4 3 -.0551143 -.033673316 1 15 2011 4 3 -.0551143 -.033673316 1 15 2012 4 3 -.0551143 -.033673316 1 15 2013 4 3 -.0551143 -.033673316 1 15 2014 4 3 -.0551143 -.033673316 1 15 2015 4 3 -.0551143 -.033673316 1 15 2016 4 3 -.0551143 -.033673316 1 15 2017 4 3 -.0551143 -.033673316 1 17 2006 4 3 -.0551143 -.033673316 1 17 2007 4 3 -.0551143 -.033673316 1 17 2008 4 3 -.0551143 -.033673316 1 17 2009 4 3 -.0551143 -.033673316 end
Code:
graph bar avgdeloxy_mme_pc avgdeloxy_mme_pc_s, over(pre_rateq pre_rateq_s, relabel(1 "Q > uartile 1" 2 "Quartile 2" 3 "Quartile 3" 4 "Quartile 4")) ytitle(∆ orig. OxyContin supp > ly rate, margin(vlarge)) /// > leg(order(1 "County" 2 "State")) too many variables specified r(103);
I am able to separately plot
avgdeloxy_mme_pc against pre_rateq and in another bar graph avgdeloxy_mme_pc_s againt pre_rateq_s as follows:
Code:
graph bar avgdeloxy_mme_pc, over(pre_rateq, relabel(1 "Quartile 1" 2 "Quartile 2" 3 "Quartile 3" 4 "Quartile 4")) ytitle(∆ orig. OxyContin supply rate, margin(vlarge)) name(a) graph bar avgdeloxy_mme_pc_s, over(pre_rateq_s, relabel(1 "Quartile 1" 2 "Quartile 2" 3 "Quartile 3" 4 "Quartile 4")) ytitle(∆ orig. OxyContin supply rate, margin(vlarge)) name(b) graph combine a b
pre_rateq for county and pre_rateq_s for state are not perfectly correlated. Counties in the first county quartile may be fourth state quartile].
I will grateful for any help you may be able to offer.
Sincerely,
Sumedha.
I will grateful for any help you may be able to offer.
Sincerely,
Sumedha.
0 Response to Graph bar
Post a Comment