Andrey
Unless the command you are iterating for the by variables allows some
way to save values, or if you actually add that feature to the ado you
are calling, I don't believe what you want is possible within the
context of the by command.
There is an alternative, however:
===============================
// This assumes variables region and group are numeric
// If they are strings the commands postfile and post and the ifcmd must
// be altered accordingly
tempname h
postfile `h' region_level group_level count using mycounts, replace
levelsof region, local(l_region)
levelsof group, local(l_group)
foreach region_level of local l_region {
foreach group_level of local l_group {
count if region==`region_level' & group==`group_level'
// count is returned in r(N) so
local count=`r(N)'
post `h' (`region_level') (`group_level') (`count')
}
}
postclose `h'
use mycounts, clear
browse
=============================
With a little work, this could be adoed to accept a more general case
of passthru commands and capture the postfile output, even
transferring variable and value labels to the new file.
DCE
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/