I have a panel with 12 individuals from a company and daily data from 2010 to 2020.
I have a dummy called cowrk that takes value 1 each time a coworker attended a company meeting.
I am trying to do a bar graph of percentage of total coworkers at team meetings per month of year, and for that I'm using:
Code:
preserve collapse cowrk, by(yr month) graph bar cowrk, over(yr) over(month) restore
But I have 4 events that mark like a before and after (one of them is covid-19, obviously), and I would like to mark them in the graph, but I am unaware of how to do this, especially because the events occur on specific dates (dd/mm/yyyy), whereas I'm displaying a graph that only has months and years on it's x axis.
Essentially, I would love to have something like this:
Array
(not exactly with the different colours, but just to mark the beginning and end of a given period in the company).
I basically want to remark the 5 periods in between those 4 events.
I created a dummy variable called event which is equal to 1 on the event dates, I am not sure if that helps or even what am I supposed to do with it to be honest.
I apologise for my ignorance and I'd be grateful for any insight you might have.
I leave a sample of my data (after the collapse command):
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(month yr cowrk) 4 2010 .24242425 5 2010 .3333333 6 2010 .530303 7 2010 .09469697 8 2010 .21969697 9 2010 .469697 10 2010 .234127 11 2010 .344697 12 2010 .1521739 1 2011 .07936508 2 2011 0 3 2011 .2463768 4 2011 .3650794 5 2011 .4545455 6 2011 .6098485 7 2011 .734127 8 2011 .3876812 9 2011 .4318182 10 2011 .3174603 11 2011 .75 12 2011 .344697 1 2012 .1628788 2 2012 .0873016 3 2012 .04166667 4 2012 .25 5 2012 .3224638 6 2012 .19444445 7 2012 .1590909 8 2012 .04710145 9 2012 0 10 2012 0 11 2012 0 12 2012 .009259259 1 2013 .010869565 2 2013 .1125 3 2013 .3214286 4 2013 .3143939 5 2013 .014492754 6 2013 .13333334 7 2013 .13043478 8 2013 0 9 2013 0 10 2013 0 11 2013 0 12 2013 .0871212 1 2014 .09126984 2 2014 .03508772 3 2014 .0873016 4 2014 .07936508 5 2014 0 6 2014 .07539683 7 2014 .06060606 8 2014 .05555556 9 2014 .01984127 10 2014 .11956522 11 2014 .065789476 12 2014 .05681818 1 2015 .0625 2 2015 .004385965 3 2015 .07954545 4 2015 .17857143 5 2015 .19166666 6 2015 .6590909 7 2015 .29545453 8 2015 .05952381 9 2015 .08333334 10 2015 .015151516 11 2015 .0375 12 2015 .11363637 1 2016 .495614 2 2016 .7125 3 2016 .06060606 4 2016 .06746032 5 2016 .023809524 6 2016 .4204545 7 2016 .008333334 8 2016 0 9 2016 .08333334 10 2016 .13095239 11 2016 .6428571 12 2016 .1626984 1 2017 .17083333 2 2017 .6447368 3 2017 .03985507 4 2017 .08333334 5 2017 .011363637 6 2017 0 7 2017 0 8 2017 0 9 2017 .0625 10 2017 .1590909 11 2017 .1031746 12 2017 .08333334 1 2018 .11507937 2 2018 .1622807 3 2018 .2063492 4 2018 .06349207 5 2018 .3522727 6 2018 .5119048 7 2018 .007936508 end
Thank you in advance,
Cheers,
Jonas
0 Response to bar graph with event markers
Post a Comment