Hell everyone,

I want to observe the sd and mean of each of the countries in my panel dataset seperately to just get an overview.
Hence I used -tabstat- and ran a loop.

The dataset currently contains 11 countries, however it was originally larger (when I encoded it). Hence, the country variable does not run from 1 to 11, but from 1 to 23 with gaps.

To make it clearer, what I want to loop is:
Code:
tabstat $xlist if country1 == 1, stat(mean sd)
tabstat $xlist if country1 == 2, stat(mean sd)
tabstat $xlist if country1 == 8, stat(mean sd)
tabstat $xlist if country1 == 11, stat(mean sd)
.
.
.
I ran:
Code:
global xlist ca total_inv savings savinv nom_gdp_pc real_gdp_pc nom_catch_up catch_up nom_short_i real_short_i_pc real_short_i_gdp nom_long_i real_long_i_pc real_long_i_gdp tot reer_cp reer_tv erer mis_tv inflationpercentagechangeavrcp ncpi private_inv net_lending_borrowing lvl_dev depend depend_old depend_young unemply world_gdp_changes nom_us_gdp_pc fd_index

forvalue i == 1(1)23{
tabstat $xlist if country1 == `i', stat(mean sd)
}
However Stata stops after the first 2 countries or at the first gap, respectivly.
Interestingly, if I use -summarize- the code runs fine and just displays 0 as resluts when there is no country identifier.
Code:
forvalue i == 1(1)23{
summarize $xlist if country1 == `i'
}
But -summarize- gives unnecessary descriptives.

Any advise or hint is appreciated.

Thank you and stay healthy.

Philipp