Aug 20, 2015

Random graphs (51): Bar graph


// Data from 
// de Mouzon, Jacques, Veerle Goossens, Siladitya Bhattacharya, José Antonio 
//     Castilla, Anna Pia Ferraretti, V. Korsak, Markus Kupka, Karl-Gösta 
//     Nygren, Anders Nyboe Andersen, and the European IVF Monitoring
//     Consortium for the European Society of Human Reproduction and Embryology.
//     2012. "Assisted Reproductive Technology in Europe, 2007. Results
//     Generated from European Registers by ESHRE." Human Reproduction 27(4):
//     954-966. doi: 10.1093/humrep/des023
// Ferraretti, Anna Pia, Veerle Goossens, Jacques de Mouzon, Siladitya 
//     Bhattacharya, José Antonio Castilla, Vladislav Korsak, Markus Kupka, Karl
//     G. Nygren, Anders Nyboe Andersen, and the European IVF Monitoring
//     Consortium for the European Society of Human Reproduction and Embryology.
//     2012. "Assisted Reproductive Technology in Europe, 2008. Results
//     Generated from European Registers by ESHRE." Human Reproduction 27(9):
//     2571-2584. doi: 10.1093/humrep/des255
// Ferraretti, Anna Pia, Veerle Goossens, Markus Kupka, Siladitya Bhattacharya,
//     Jacques De Mouzon, José Antonio Castilla, Karin Erb, Vladislav Korsak,
//     Anders Nyboe Andersen, and the European IVF Monitoring Consortium for the
//     European Society of Human Reproduction and Embryology. 2013. "Assisted
//     Reproductive Technology in Europe, 2009. Results Generated from European
//     Registers by ESHRE." Human Reproduction 28(9):2318-2331. doi:
//     10.1093/humrep/det278
// Kupka, Markus S., Anna Pia Ferraretti, Jacques De Mouzon, Karin Erb, Thomas
//     D'Hooghe, José Antonio Castilla, Carlos Calhaz-Jorge, Christian De
//     Geyter, Veerle Goossens, and the European IVF Monitoring Consortium for
//     the European Society of Human Reproduction and Embryology. 2014.
//     "Assisted Reproductive Technology in Europe, 2010. Results Generated from
//     European Registers by ESHRE." Human Reproduction 29(10):2099-2113. doi:
//     10.1093/humrep/deu175
// Always the two right-hands columns of Table 1
// "Cycles/million women 15–45 y" and "Cycles/million population"--Cycles of 
// IVF, ICSI, and FER


// Fix country variable
kountry cntry, from(other) stuck marker
ren  _ISO3N_ country
kountry country, from(iso3n) to(iso2c)
ren _ISO2C_ geo
drop country
ren cntry country
ren geo cntry
order cntry country
drop MARKER

// Fix string numbers
replace cycmio1545x2010 = subinstr(cycmio1545x2010, " ", "",.)  // Remove blank (thousands separator)
replace cycmio1545x2009 = subinstr(cycmio1545x2009, " ", "",.)  
replace cycmio1545x2008 = subinstr(cycmio1545x2008, " ", "",.)  
replace cycmio1545x2007 = subinstr(cycmio1545x2007, " ", "",.)  

destring cycmio1545x2010 cycmio1545x2009 cycmio1545x2008 cycmio1545x2007, replace
*list

// Turn data set around
reshape long cycmio1545x cycmio, i(cntry) j(year)
list, sepby(cntry)

// Cross-sectional bar graph at latest point in time
replace cycmio1545x = . if cntry == "DK" & year == 2010 // Get rid of dodgy DK 2010 value

by cntry: egen lastobs = max(cond(!missing(cycmio1545x), year, .))  // Identify year of latest observation
gen byte last = year == lastobs                            // ID variable of latest observation
// According to http://www.stata.com/support/faqs/data-management/first-and-last-occurrences/

graph hbar cycmio1545x if last == 1, over(country, sort(cycmio1545x) descending) nofill ///
      ytitle("ART cycles per million women age 15{c 150}45", size(medsmall)) ylabel(0(2500)15000, ang(45)) ///
      /*note("{it:Note:} Data refer to 2010 or latest available (no earlier than 2007)", span) */ ///
      name(figure1, replace) ysize(6.5) xsize(5.5) scheme(lean1)

// Figure 1: ART cycles per million women age 15–45 per country, 2010
// Sources: Ferraretti et al. (2012; 2013) and Kupka et al. (2014).
// Notes: Values for Albania, Estonia, Ireland, Lithuania, Poland, Spain, 
// Serbia, Switzerland, and Ukraine refer to 2008; for Croatia, Cyprus, France, 
// and Denmark to 2009.  ART cycles refer to IVF, ICSI, frozen embryo 
// replacement (thawings), preimplantation genetic diagnosis and screening, egg
// donation (donation cycles), in vitro maturation, and frozen oocyte
// replacement (thawings).