Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str32 country int year float(rank_NGDPRPC rank_NGDPDPC rank_NGSD_NGDP rank_PCPIPCH)
"Greece"  2010 2 2 4 1
"Estonia" 2010 4 4 1 2
"Cyprus"  2010 1 1 3 3
"Malta"   2010 3 3 2 4
"Greece"  2011 2 2 4 3
"Malta"   2011 3 3 2 4
"Estonia" 2011 4 4 1 1
"Cyprus"  2011 1 1 3 2
"Malta"   2012 3 3 2 2
"Greece"  2012 2 2 4 4
"Cyprus"  2012 1 1 3 3
"Estonia" 2012 4 4 1 1
"Estonia" 2013 4 4 1 1
"Greece"  2013 3 3 3 4
"Malta"   2013 2 2 2 2
"Cyprus"  2013 1 1 4 3
"Cyprus"  2014 2 1 4 3
"Estonia" 2014 4 4 1 2
"Malta"   2014 1 2 2 1
"Greece"  2014 3 3 3 4
end
Q1. I am trying to plot rank_* variables of countries by year. For example, the following code does the job (partially) for the variable rank_NGDPRPC .
Code:
graph hbar (asis) rank_NGDPRPC, over(country) by(year)
. This plot, however, is not sorted. How could I attain a plot that always puts country with rank 1 on top then country with rank 2 and so on?

Q2. How do I apply the above requested code to all rank_* variables using loop?

Q3. Instead of showing all the plots in one graph, how do I generate individual plots for each year for all the rank_* variables?