If I understand this correctly, your data structure
is awkward at best for what you want to do.
I'd try a -reshape-, after which things should be
easier.
gen id = _n
reshape long v category_v , i(id)
egen mean = mean(v), by(_j category_v)
egen sd = sd(v), by(_j category_v)
tabdisp _j category_v , c(mean sd)
Nick
n.j.cox@durham.ac.uk
Camelia Minoiu
> Thank you very much for your help. I have studied all
> responses carefully. I
> should have mentioned that each variable in the list v1 to v100 has a
> variable called "category_v*" in the dataset. The variables
> category_v1 to
> category_v100 contain a breakout of the values of each v
> variable into five
> categories (1 to 5). I then want to obtain summary statistics
> (one at a
> time, indeed -- I initially thought that I could have 2
> summary statistics
> and then the matrix with results for the 2nd would be
> appended to the matrix
> for the 1st summary statistic) from the cells in the v's by the
> category_v's. Unfortunately, I still don't know how to do it
> in Stata.
>
> In other words, I have the dataset:
>
> v1 v2 category_v1 category_v2
>
> x11 x21 1 2
> x12 x22 1 2
> x13 x23 2 1
> x14 x24 2 1
>
> I would like to obtain a matrix which gives me the mean of
> x11 and x12 in
> the first cell, and then the mean of x23 and x24 in the
> second cell (by
> category 1). The same for category 2 correspoding x's, whose
> means should be
> put in the second row of the matrix. Would this be possible?
*
* 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/