Dear Statalisters,

I saw this old forum discussion , my question is about understanding the code :

original forum list is here
https://www.stata.com/statalist/arch.../msg01036.html


Johanna asked the question
Code:
I have a panel of European regions over time. I would like to plot a
variable against time for these regions grouped by countries - that is, I would
like to have all the regions of one country in one plot, and the plots of all
countries together on the same overall graph.
Nick helped him/her out with a code sketch here:
Code:
egen country2 = group(country) 
sum country2, meanonly 

forval i = 1/`r(mean)' { 
    xtline response time if country2 == `i' , overlay name(gr`i') 
    local graphs `graphs' gr`i'
} 

graph combine `graphs'

i know Nick uses egen to generate country code . I think the sum function meanonly, will generate the mean of the country2 variable.

e.g. original data has 3 countries, then

sum country2, meanonly

gives 2 ?

my question is about what value goes in to the forval loop, is it the average 2 from above? without the data of the orignal poster and my limited stata knowledge, I am not sure about my interpretation.

Thank you in advance !

Code:
forval i = 1/`r(mean)'
Rochelle