My point is that I don't think you need to 
write a program at all. This should yield
to an existing command. Much of the terrain 
is surveyed in 
SJ-3-4  pr0011  . . . . . . . .  Speaking Stata: Problems with tables, Part II
        Q4/03   SJ 3(4):420--439 
        reviews three user-written commands (tabcount, makematrix,
        and groups) as different approaches to tabulation problems
SJ-3-3  pr0010  . . . . . . . .  Speaking Stata:  Problems with tables, Part I
        Q3/03   SJ 3(3):309--324 
        presents ways of preparing material for tabulation
Nick 
[email protected] 
Hui Wang/Jackie 
 
> Hi, Nick,
> 
> Can you recommand any other commands which can help me to 
> write the program 
> more efficiently?
 
Nick Cox
> >You can nest -forval- loops. But your example
> >shows that you know that already, so I
> >can't see what's behind this post.
> >
> >However, a larger question is why you are
> >doing it this way. Your table problem
> >does not look very unusual.
Hui Wang
> > > I am trying to do a table contenting condictional counting
> > > results in each
> > > cell. To output the table automatically, I want to save the
> > > count result in
> > > macros and then use 'display' to show them in rows and columns.
> > >
> > > The following is the main code. Where each row is the
> > > individual's current
> > > age and each column is the age at marriage, so that the
> > > number in row i and
> > > column j represents the number of people who is i years old
> > > now got married
> > > when he is j years old.
> > >
*
*   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/