Announcement

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

  • Bar graphs with line

    Dear All
    I have a panel data set (long) including 1245 firms over 10 years (2007-2016) with multiple firm characteristics (firm name, country, industry, year, DSO, DIO, DPO, CCC, leverage, growth, size, etc.) so every row/observation represents a firm-year.
    I would like to create a graph like the one below/attached with my data (yearly mean of DSO, DIO and DPO as bar graphs with a line graph of mean CCC). I would like to create this graph once for my entire data but also once for each sector as well as each country separately.
    Is it also possible to create such a graph using the medians?

    Thank you very much in advance for your helpful responses!
    Vivien

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str76 COMPANY int year str14 COUNTRY str27 SECTOR double(DPO DSO DIO CCC GROWTH LEV SIZE_LNTA ROA)
    "21st Century Technology PLC"                    2007 "United Kingdom" "Technology"              49.76728768345999  91.82755989373702  55.36701510547565    97.4272873157527   -.07094796166209166 .46760933903321433  3.211742830078779   .054203661076400275
    "21st Century Technology PLC"                    2008 "United Kingdom" "Technology"              78.44237498548569 153.40523898103973  75.03635956674339  149.99922356229743    -.6151534856863113  .3889114541023563 2.7380554508006867   -.03188464662875716
    "21st Century Technology PLC"                    2009 "United Kingdom" "Technology"             35.308886766025175  64.35622891288838  53.16181239539207   82.20915454225528     .4600768999979168  .3242220353238024  2.596491630822129    .04196804037005898
    "21st Century Technology PLC"                    2010 "United Kingdom" "Technology"             22.676938154013076  55.73898536039867   44.8234429477272    77.8854901541128    .06993466765472521 .24658254468980023 2.5883279706847095    .05432877672625297
    "21st Century Technology PLC"                    2011 "United Kingdom" "Technology"             31.618251735717216 39.692858751763815 39.312491555548924   47.38709857159552     .3297141183703392  .2570475901788419  2.762297448013138    .08866323128220635
    "21st Century Technology PLC"                    2012 "United Kingdom" "Technology"             31.121680969499636  52.92949484500891 51.316861023483135   73.12467489899241   .027809536194332254  .2925880063683011 2.6337201858101924     .1192287281089692
    "21st Century Technology PLC"                    2013 "United Kingdom" "Technology"             20.065476588303724  76.69925574164033  63.62472489031683  120.25850404365345    -.2451758743544866  .2729682879575822  2.469174642673046   -.02488018762108701
    "21st Century Technology PLC"                    2014 "United Kingdom" "Technology"              38.06937365548833 60.584931298361425 49.797862194209955   72.31341983708305    -.1088421865980785   .268977248564747 2.4939228240679068   -.04071869019774627
    "21st Century Technology PLC"                    2015 "United Kingdom" "Technology"              90.96830215477174  84.67266221547159 28.187556179700163  21.891916240400022    .42846451781462624  .7404329761644416  2.518656387078679    -.5275530286464022
    "21st Century Technology PLC"                    2016 "United Kingdom" "Technology"              170.5583691964815 136.84594883599107   43.6133879808962   9.900967620405766    -.1832128141642182  .9504402515723264  2.233072214902751   -.28968553459119506
    "3U Holding AG"                                  2007 "Germany"        "Industrials"             47.82730768166855  38.54858786755553 3.5371543433561077   -5.74156547075691     .2366080591092564  .5798280641706948  4.604379873773648    .01564235746239529
    "3U Holding AG"                                  2008 "Germany"        "Industrials"             42.82658967606249  37.79955610977209  3.569873160926493 -1.4571604053639078  -.009165260527601816  .5510545970659748  4.453847171211826   -.04631385460171947
    "3U Holding AG"                                  2009 "Germany"        "Industrials"             42.86206702711542 45.613342054966736  .5558508191862308   3.307125847037547   -.08950390381447816  .5225485188968336  4.360802998222255  .0004851889683350358
    "3U Holding AG"                                  2010 "Germany"        "Industrials"             64.82066338676401  82.49573480399937  5.224319552451992  22.899390969687346    -.4847967620936008 .48041641559507176  4.356696006094587  -.018205361607200092
    "3U Holding AG"                                  2011 "Germany"        "Industrials"             42.77451622290121 54.622544740288085  9.630838061981665  21.478866579368542    .36347405173781944 .16412512089455344  4.323854471869926   -.03708316220405676
    "3U Holding AG"                                  2012 "Germany"        "Industrials"            25.954926299456943  44.00954228083786 12.402637703646237  30.457253685027155  -.062272661137785554 .14238141650422353  4.120012308970678   -.17267706302794023
    "3U Holding AG"                                  2013 "Germany"        "Industrials"             29.84667802385008  59.08450454287337 18.092821313647544   47.33064783267083    -.3442358417377812 .17412569024454377  4.043840430048332    -.0852835480760803
    "3U Holding AG"                                  2014 "Germany"        "Industrials"            25.081284153005466 47.783372365339574 24.187304839968775   46.88939305230288    .21237932992617828  .5044334515587082  4.450992839138604   -.04236279634123576
    "3U Holding AG"                                  2015 "Germany"        "Industrials"             24.71102323282254 46.549678695007415  41.13331685615423    62.9719723183391  -.012978142076502715  .4818006665278067  4.341412951788585  -.009568319100187461
    "3U Holding AG"                                  2016 "Germany"        "Industrials"             32.65657539102308  46.98956533297886  87.31196552793655  101.64495546989234   -.10750370736529914  .5767632254965435  4.561865946578819   .007215805852008103
    "4Sc AG"                                         2007 "Germany"        "Healthcare"             129.84556686046514 153.71911337209303  4.774709302325582  28.648255813953483    -.6244541484716157 .11090966776956897 3.0939019973262343     -.368490232515977
    "4Sc AG"                                         2012 "Germany"        "Healthcare"             54.041465655869516 134.20227429359065 1.9704801286469102   82.13128876636803      4.58076923076923 .24956135824130454 3.3696035100709767    -.4547080882099976
    "4Sc AG"                                         2013 "Germany"        "Healthcare"              46.85307911908645 127.64579934747145 1.6746533442088092    82.4673735725938    .12657937054904667 .36277887602372216  2.873847085563867    -.5944648404405536
    "4Sc AG"                                         2014 "Germany"        "Healthcare"              43.14812189936216  26.41141034727144 1.2416725726435154 -15.495038979447205    .43862153344208804  .8627293424400697   2.70364049261351    -.6492567296102852
    "4imprint Group PLC"                             2007 "United Kingdom" "Consumer Cyclicals"      37.37251044468595  59.18579388057189  22.96894989856256    44.7822333344485    .19733223223119858  .6384142763445507   4.52810091428275   .032749810683725546
    "4imprint Group PLC"                             2008 "United Kingdom" "Consumer Cyclicals"      37.81471747445611 48.575766045961316  17.79987696589963  28.560925537404835    .10131198217676028  .7035054714137968 4.2901477565695245    .06362818505962337
    "4imprint Group PLC"                             2009 "United Kingdom" "Consumer Cyclicals"      42.75947525045678 43.402597818554106 16.575360078550702  17.218482646648027   -.16231278013157763   .783643201551085  4.330130802699381   .034430788933291816
    "4imprint Group PLC"                             2010 "United Kingdom" "Consumer Cyclicals"      46.25022207178488  53.06068904347354 16.825143766934715  23.635610738623377   -.09932149380532652  .7686911195100232  4.463212524829102   .039466812945542676
    "4imprint Group PLC"                             2011 "United Kingdom" "Consumer Cyclicals"      35.17601645387014  39.69801448501289  9.869439994060157  14.391438025202909    .18610817711179906    .82051493759947  4.469371631264115   -.02259004989209076
    "4imprint Group PLC"                             2012 "United Kingdom" "Consumer Cyclicals"     28.283398329710842 32.786037801672194  6.099570318081984   10.60220979004334    .11850125540296277  .7709241589207864  4.298650774631349    .07025572715308052
    "4imprint Group PLC"                             2013 "United Kingdom" "Consumer Cyclicals"       26.2634262771213 29.515674029062705  5.094566770619091   8.346814522560496    .10101402758078037   .692843107869584  4.182911569216697    .11783838989354026
    "4imprint Group PLC"                             2014 "United Kingdom" "Consumer Cyclicals"     19.919217664022227  18.16682741158822 3.3442546240264854  1.5918643715924787     .4094408695109606  .8115481978543014  4.116164091458351    .21908359116540094
    "4imprint Group PLC"                             2015 "United Kingdom" "Consumer Cyclicals"       19.5707124636383  17.44440991345668 3.0619141546669795   .9356116044853593     .3409360999985676  .6831202387846929  4.415134377600082     .2527620617454448
    "4imprint Group PLC"                             2016 "United Kingdom" "Consumer Cyclicals"      20.15848932592326  16.60918175189164 2.7780259623010415  -.7712816117305792     .1595291019464831  .6767241379310345  4.457658719063974    .26984301966663726
    "600 Group PLC"                                  2007 "United Kingdom" "Industrials"             54.84672420911445    72.644634304499 103.47552916940126   121.2734392647858    .09466706841445573  .4012204074142043  4.567987612175217    .03418058359331981
    "600 Group PLC"                                  2008 "United Kingdom" "Industrials"             68.60154776346356  84.62534761920296 118.92736506434022  134.95116492007963   -.12311208212570741 .40693256617520585  4.391206188396731   .031238762332119033
    "600 Group PLC"                                  2009 "United Kingdom" "Industrials"              62.4361602599126  68.41851426842926 127.55337031013013  133.53572431864683   -.16022820409874902 .42903862528059494  4.019239533913847   -.14648966638284708
    "600 Group PLC"                                  2010 "United Kingdom" "Industrials"             61.47868002153301  67.37010884201779 172.77839502629774   178.6698238467825    -.3773608780693818   .539206663292071 3.8908673616651317    -.2005430030831529
    "600 Group PLC"                                  2011 "United Kingdom" "Industrials"              68.0811542682888  75.16656772372083 190.41641942037475  197.50183287580677   -.19240719291450026  .5007483134166834 3.8954709792824787    .04634938177799276
    "600 Group PLC"                                  2012 "United Kingdom" "Industrials"             61.98426207699424  60.74223035737271 138.45106841380704   137.2090366941855    .09202291080859164  .7960059560304807    3.7159412536008   -.28005021751189807
    "600 Group PLC"                                  2013 "United Kingdom" "Industrials"             43.14032593431727  47.85469604444986  92.63621489025339   97.35058500038596    .09946118281387034   .513358649978654  3.966065869705537    .05294025121901889
    "600 Group PLC"                                  2014 "United Kingdom" "Industrials"            31.026896271892415  46.56573531312881  81.28358051061971   96.82241955185612     .0180945970144641  .4844854000411589 3.9684853076747304    .04234788374911396
    "600 Group PLC"                                  2015 "United Kingdom" "Industrials"              25.2975021124229  44.67488194540612  77.36977923663764   96.74715906962086     .1859688316322326  .5162034770689679  4.581770011305192    .03286851196553703
    "600 Group PLC"                                  2016 "United Kingdom" "Industrials"            27.775321815216735  49.09903091688575  94.11204944274505  115.43575854441406   -.05514028744995535   .468035221174386  4.563110046212338   .014927317251081087
    "7C Solarparken AG"                              2007 "Germany"        "Utilities"               24.80040626283837 16.003218149449946 44.344159401104676   35.54697128771626     .3985795227834969  .4209427476107342  4.017481516284286  -.012094814708158602
    "7C Solarparken AG"                              2009 "Germany"        "Utilities"               77.81988654270407 10.300002488098595 31.967090749249422  -35.55279330535605    14.594154164511123  .6357812248536093  5.777986632660106    .01776186290652042
    "7C Solarparken AG"                              2010 "Germany"        "Utilities"              48.835954829602734   9.31728927203065  60.44967483363581  20.931009276063726     .6451307910494801  .7669419240535195  5.429472813848555    -.2866477509439589
    "7C Solarparken AG"                              2011 "Germany"        "Utilities"               79.96634419400063 28.283081619058034  83.76052676059139    32.0772641856488   -.49295724944545277  .7963233818004532  4.937892543449571   -.16437953483036508
    "7C Solarparken AG"                              2012 "Germany"        "Utilities"               58.65016189962223  85.03112712975099 11.368437283170149  37.749402513298904    -.7420682661045766  .8414806557733613   4.29812858805602   -.06160789538076725
    "7C Solarparken AG"                              2013 "Germany"        "Utilities"              28.633743649863227 22.447000781555293  4.403819851504494 -1.7829230168034407    -.6054274920977565   .790648870981281 4.6748548181534435  .0036468097409925668
    "7C Solarparken AG"                              2014 "Germany"        "Utilities"               35.83029824079164 24.493025013743814  5.593389224848818   -5.74388400219901     .4216490816725282  .8158215146804753  5.336542391860967    .03578561356734827
    "7C Solarparken AG"                              2015 "Germany"        "Utilities"               27.63908603422443  18.83861682832584  3.324461793233972  -5.476007412664618     .7428532160527762  .7650993782720041  5.578770875774367   .020929494685472116
    "7C Solarparken AG"                              2016 "Germany"        "Utilities"               56.03197002706807  16.18728130983033 3.8133788869082985  -36.03130983032944    .19446415897799868  .7522372247538264  5.652710208471697   .016508631425334052
    "7digital Group plc"                             2007 "United Kingdom" "Consumer Cyclicals"      56.84036283247728 104.40555858801615 1.1028195759001718   48.66801533143904    -.2998443524827151  .3514264074728602 2.8627576640941443   -.07254060422452267
    "7digital Group plc"                             2009 "United Kingdom" "Consumer Cyclicals"     60.860019525570706  236.6719866576975  8.358371075479234    184.170338207606   -.24061352400842334 .37032666749472126 2.8569565980384404   -.04732331387405291
    "7digital Group plc"                             2010 "United Kingdom" "Consumer Cyclicals"     46.232725701856495   88.7680938771013  6.074748979256627  48.610117154501424     .4566744219493445 .38456275656176203  2.894136137548722   -.03383505411120792
    "7digital Group plc"                             2011 "United Kingdom" "Consumer Cyclicals"       33.8591115945537  86.97813703469019   9.39008816334058   62.50911360347707   -.09075605493867156  .1751327433628316  2.548561696124731   -.06530973451327408
    "7digital Group plc"                             2012 "United Kingdom" "Consumer Cyclicals"      32.72641098470673  81.91020305025295 16.362227437059396    65.5460195026056   -.23336869748571068 .20647287983218515  2.080444872567682   -.33008690440515476
    "7digital Group plc"                             2013 "United Kingdom" "Consumer Cyclicals"      23.29936470556136  49.64735260590111 13.570968257669545  39.918956158009294    .15261780095741764 .19912790697674493 1.8759843677063865   -.16170058139534868
    "7digital Group plc"                             2014 "United Kingdom" "Consumer Cyclicals"      16.64592230550631  49.11350514424951  3.025013814757363   35.49259665350056    1.9477504277268836  .3093346573982116  3.032139376521263   -.16317030784508385
    "7digital Group plc"                             2015 "United Kingdom" "Consumer Cyclicals"     21.302515237414646  110.6744797380663  1.821813267319898   91.19377776797154    .07265789461475995  .5414906663033114 2.2985423554057394   -1.0745333151655498
    "7digital Group plc"                             2016 "United Kingdom" "Consumer Cyclicals"     30.891908579050554 116.95930801112607 3.8145085805680368   89.88190801264355  -.009971345171912232 1.2132193268186726  2.157046585189516    -.7254343105320299
    "A.G.Barr PLC"                                   2007 "United Kingdom" "Consumer Non-Cyclicals" 16.163147348342527  60.28155548378707  30.93766192151708   75.05607005696163    -.0688541071194405 .31464280228619523  5.118735072028397    .13612074471095184
    "A.G.Barr PLC"                                   2008 "United Kingdom" "Consumer Non-Cyclicals"  16.42564161377082  55.84291146471042  31.42232117244214   70.83959102338174   -.03935028755574109  .5042319380243098  5.357112300487695    .09135315014552328
    "A.G.Barr PLC"                                   2009 "United Kingdom" "Consumer Non-Cyclicals" 11.198612586279351  46.38870879799665 27.475799503817054   62.66589571553435     .2073380640618123 .47615821211347503  5.400382974419964    .09354299026940269
    "A.G.Barr PLC"                                   2010 "United Kingdom" "Consumer Non-Cyclicals"  8.984806878027548  48.43380134431775 30.122963372007774   69.57195783829798    .11424780094130697 .42273981817642203 5.4618963574437265    .11171070464055725
    "A.G.Barr PLC"                                   2011 "United Kingdom" "Consumer Non-Cyclicals" 12.510288479580797 55.874871150653384   32.2172921305088   75.58187480158139   .023608061636401046  .3527643312101908  5.453110080415042    .14341910828025473
    "A.G.Barr PLC"                                   2012 "United Kingdom" "Consumer Non-Cyclicals"  16.69266244301546  61.19064791997155 30.754012833374873   75.25199831033096   .051788220492579876  .3918766698628734  5.530234513691734     .1181681080628194
    "A.G.Barr PLC"                                   2013 "United Kingdom" "Consumer Non-Cyclicals"  15.52781312326471  61.83466473139003  26.08594930511901   72.39280091324433    .09788631909124498  .3157611713991021  5.611030545238669    .12420550613997192
    "A.G.Barr PLC"                                   2014 "United Kingdom" "Consumer Non-Cyclicals"   18.2783115240419  62.69734047328435 21.839715164802563   66.25874411404502     .1393810599676851  .3855101023384357   5.83090779142603     .1177657482246816
    "A.G.Barr PLC"                                   2015 "United Kingdom" "Consumer Non-Cyclicals"  18.60400527521936   70.5253880425066 23.039930798051543   74.96131356533878  -.025460107710263684 .33048327137546524  5.868428878316495    .12750929368029723
    "A.G.Barr PLC"                                   2016 "United Kingdom" "Consumer Non-Cyclicals" 17.898188341429144  74.06332126144712 24.690984549401925    80.8561174694199   -.11292334477354597  .3403483309143677  5.778661510287361    .12917271407837452
    "A2A SpA"                                        2007 "Italy"          "Utilities"               41.57160625444208 167.38894811656004 19.910270078180524   145.7276119402985    -.5942321557317952  .6697354961274294  8.830981510952498    .05392371766768961
    "A2A SpA"                                        2008 "Italy"          "Utilities"               54.41458811946177  77.89341975713818  7.426977354775188  30.905808992451597    1.1656005685856432  .6524625459764959  9.318925682389624    .03095003139858258
    "A2A SpA"                                        2009 "Italy"          "Utilities"               75.89242732827253 117.21764488057767 14.022866135900758   55.34808368820589   -.11371841155234658  .6975409836065574  9.409191230721348   .007213114754098361
    "A2A SpA"                                        2010 "Italy"          "Utilities"               75.13284224466149 118.15220989902333 12.960188710478398  55.979556364840235    .11849657470838734  .7065627357304501    9.3868953338758   .019696588718464504
    "A2A SpA"                                        2011 "Italy"          "Utilities"               82.02079934747145 122.03384991843394 15.004893964110929  55.017944535073426   .014732660155603377  .7450944265315523  9.292381082312392  -.010225702441271304
    "A2A SpA"                                        2012 "Italy"          "Utilities"               74.71797839506174   108.852237654321  17.06712962962963    51.2013888888889   .057096247960848286  .7617413143574717   9.38806805975991    .01992465466722478
    "A2A SpA"                                        2013 "Italy"          "Utilities"               85.42068165596004 123.62062812276946  20.32119914346895   58.52114561027838   -.13518518518518519   .746503178928247  9.306559229716726   .006811989100817439
    "A2A SpA"                                        2014 "Italy"          "Utilities"               93.26394462279293 127.42776886035314 20.798555377207062   54.96237961476726   -.11063526052819414  .7504113035904384  9.243097936214355 -.0017419916771508758
    "A2A SpA"                                        2015 "Italy"          "Utilities"               89.52550294655558 114.07640723430197 17.356228408859987   41.90713269660637  -.012640449438202247  .7300275482093664   9.19023970026918 -.0058157330884603614
    "A2A SpA"                                        2016 "Italy"          "Utilities"               91.23208325152169  118.4655409385431 12.290889456116238  39.524347143137646    .03495224547856127  .7382214086135466   9.24753981296529   .022834569804412758
    "ACS Actividades de Construccion y Servicios SA" 2007 "Spain"          "Industrials"            132.67255823724116 152.07122544081966 18.869662897048816   38.26833010062731    .08373317423304491  .9061618507478528  10.81161392655746   .018532268095758784
    "ACS Actividades de Construccion y Servicios SA" 2008 "Spain"          "Industrials"             72.31548154972148 154.03899114868932 18.390155325961093  100.11366492492894 -.0009193182222745826  .9345944410998336 10.840117238445798   .019729748903333427
    "ACS Actividades de Construccion y Servicios SA" 2009 "Spain"          "Industrials"             67.52957948276915 139.77413603012485  15.60465578624783   87.84921233360353 -.0014480970900393715  .8654502440181328  10.35332654771914   .027541585310814378
    "ACS Actividades de Construccion y Servicios SA" 2010 "Spain"          "Industrials"             77.69796079307785  148.6742751752262 15.823619301680559   86.79993368382891   -.07028578498772482  .8777649607379385 10.439528393774182    .03724571061053441
    "ACS Actividades de Construccion y Servicios SA" 2011 "Spain"          "Industrials"             72.70287093410717  99.39110577969149 15.337056123053049  42.025290968637364     .9411393700434169   .930834624413148 10.778698110731323   .022144904114726784
    "ACS Actividades de Construccion y Servicios SA" 2012 "Spain"          "Industrials"             80.38905213430358  94.03219950694052 17.561807649188417   31.20495502182534     .3485647577295818  .9360851245577357 10.634974673867829    -.0364526452326683
    "ACS Actividades de Construccion y Servicios SA" 2013 "Spain"          "Industrials"             90.64071902596032  105.2550164874583  19.43969590497184  34.053993366469825   -.08381633713647226  .9182314022344189  10.59576883331304   .027115344008122627
    "ACS Actividades de Construccion y Servicios SA" 2014 "Spain"          "Industrials"              87.5514471976895 104.64069628730485 17.524151354066383   34.61340044368174    -.0084453753432086  .9228521033495432 10.579507266863608   .011790598522636975
    "ACS Actividades de Construccion y Servicios SA" 2015 "Spain"          "Industrials"             87.67622970307355  105.3086162067103  16.39241107942016   34.02479758305691  -.045570866085297194  .9030321803156183 10.471066634825396   .028202149965130215
    "ACS Actividades de Construccion y Servicios SA" 2016 "Spain"          "Industrials"             94.17938667615402 107.31299842515509 16.408476197124195  29.542087946125264   -.03953275012406396  .8926735249705557  10.41551043929666   .017852912567802023
    "APC Technology Group plc"                       2007 "United Kingdom" "Industrials"             36.22436279952659  68.49558937073972  37.64908130940896    69.9203078806221     .5029887375004641  .6805318138651472  2.052855614019718    .11775878442545099
    "APC Technology Group plc"                       2008 "United Kingdom" "Industrials"             50.84698165236126  70.28417284025151  39.04044924092325   58.47764042881351    .04753992138456384  .6311772315653303  2.261190826201738    .09133247089262611
    "APC Technology Group plc"                       2009 "United Kingdom" "Industrials"             45.99942845371817  60.55195341361991  35.26093347470223   49.81345843460397    .05998915593863629   .676912080057183 2.0724807236470806   -.09092208720514647
    "APC Technology Group plc"                       2010 "United Kingdom" "Industrials"             37.29026252407344 59.970597118944376 30.987811222322748   53.66814581719369   .013899030055557737  .5762817515973191 2.0495747570462837   .027894654823126124
    "APC Technology Group plc"                       2011 "United Kingdom" "Industrials"             36.85885915915705  58.91984007052786 23.897916542149396   45.95889745352021   .004523315865717586  .5261001517450686 2.0081444191792226    .04476479514415783
    "APC Technology Group plc"                       2012 "United Kingdom" "Industrials"              30.1604443794223  56.52779797138857 17.480899184993287  43.848252776959555     .0560149145403645  .4514276599138614  2.067957148526853  -.005104482373584267
    "APC Technology Group plc"                       2013 "United Kingdom" "Industrials"            24.396433090677878   46.5188508374315 19.079549192202393   41.20196693895602    .47596475685182427 .30821784110872513  2.891975775013006     .2772464051011775
    "APC Technology Group plc"                       2014 "United Kingdom" "Industrials"             47.50350360824383  59.25462931028933  32.85458399068951  44.605709692735005   .026502613974257037  .2851877303679647 3.0071954390651605   .018866745798713096
    end
    Click image for larger version

Name:	C2C Graph.png
Views:	1
Size:	37.3 KB
ID:	1412599


  • #2
    That bar graph is arguably a terrible design. Most of the space is used to little effect, showing that values are similar to each other and very different from zero. I'd recommend line graphs for data like these. The scale could helpfully start at 50 or so for the example you show.

    Could you give a source for the graph? Are the data accessible? I might want to cite it as an example of what not to do.

    In Stata terms you could get it by combining twoway bar with line. The key point is that graph bar is not the place to start because then lines can't be added.

    But as said I urge something different. With a bit of work you could lose the legend (kill the key) too and reduce mental back and forth.

    I know nothing about finance to speak of. I take it from the example graph that the units are days for each variable.

    Continuing from your example (thanks!) here is some token code.

    Code:
    foreach s in mean median { 
        foreach v in DPO DSO DIO CCC { 
             egen `v'_`s' = `s'(`v'), by(year) 
             label var `v'_`s' "`s' `v'" 
        }
    } 
    
    * plot each year just once 
    egen tag = tag(year) 
    
    set scheme s1color 
    
    * change colours at will, but don't mix red and green 
    local colours "red blue black cyan" 
    tokenize "`colours'" 
    
    * common options 
    local common sort xtitle("") ms(Oh Dh X Sh) lc(`colours') mc(`colours') 
    local common `common' legend(off) xsc(r(. 2016.8)) yla(, ang(h)) 
    local common `common' xla(2007/2016, labsize(medsmall)) 
    
    * get positions for explanatory text from 2016 values 
    local j = 1 
    foreach v in DPO DSO DIO CCC { 
         su `v'_mean if year == 2016, meanonly 
         local call `call' text(`r(mean)' 2016 "  `v'", color(``j'') place(r))  
         local ++j 
    } 
        
    twoway connected ???_mean year if tag,  `common' `call'  subtitle(Means (days)) name(G1, replace) 
    
    * blank out explanatory text 
    local call 
    local j = 1 
    
    foreach v in DPO DSO DIO CCC { 
         su `v'_median if year == 2016, meanonly 
         local call `call' text(`r(mean)' 2016 "  `v'", color(``j'') place(r))   
         local ++j 
         
    } 
    
    twoway connected ???_median year if tag, `common' `call'  subtitle(Medians (days)) name(G2, replace)

    Click image for larger version

Name:	means_series.png
Views:	1
Size:	38.0 KB
ID:	1412605
    Click image for larger version

Name:	medians_series.png
Views:	1
Size:	38.4 KB
ID:	1412606



    Comment


    • #3
      Thanks Nick for your reply. The source is Losbichler, H., & Rothböck, M. (2006). Creating shareholder value through value-driven supply chain management. Managing risks in supply chains–How to build reliable collaboration in logistics, 281-296.

      Is there a way to create this graph for each country and each sector separately? I tried to do this with the keep if country==1 command but it did not work

      Thanks for your help!

      Comment


      • #4
        Thanks for the reference.

        You can just calculate means and medians by country, sector and year -- or by one or two of those -- by varying what you feed to the by() option of egen.

        Your example doesn't let us replicate

        Code:
        keep if country ==  1
        as there is no such variable in what you give us. Nor do you explain "didn't work", a phrase which has about 20 different meanings. What I can see is that you have a string variable called COUNTRY.

        I wouldn't mess around with repeated subsets of the data. The better idea is just to loop over the possibilities.

        Much depends on how many countries and sectors you have, whether you want the graphs one at a time, or in different panels etc.

        Comment


        • #5
          Sorry for the confusion, I had meant to use the variable country
          Thanks so much for your help!

          Comment

          Working...
          X