# Re: st: RE: Extracting Matrices from dataset

 From "Nadeem Shafique" To statalist@hsphsun2.harvard.edu Subject Re: st: RE: Extracting Matrices from dataset Date Mon, 20 Aug 2007 17:51:20 +0500

```Respected Nick

I am so grateful for your response. Actually i wish to split my data
set into several matrices so I can perform Multivariate ANOVA on the
extracted matrices. The solution that you have posted will simply
transform my data set into a single matrix.
Can you tell me the solution of this problem that how several matrics
can be extracted from a data set on the basis of a grouping variable.

Best Regards,

On 8/20/07, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> Two earlier versions of this posting appeared yesterday.
> They referred to Mata.
>
> As with other concurrent threads, questions that are
> not precise, or even stated, or which seem to be easily
> answerable from the documentation tend to get little or no
> response.
>
> I have two further comments:
>
> 1. Functions to read Stata variables into Mata are
> well documented in the Mata documentation. You shouldn't
> need to write any new functions. See -help m4_stata-.
>
> 2. As you don't state what you want to do with these matrices,
> it isn't clear whether your inclination to use Mata is
>
> Nick
> n.j.cox@durham.ac.uk
>
>
> > I wish to extract matrices based on a grouping varible in the dataset.
> > Consider the following example suppose I have three groups (1,2 and 3)
> > entered in "gr" variable
> >
> > m     v1      v2      v3      gr
> > **********************************
> > 23    1       2       3       1
> > 11    3       1       2       1
> > 23    2       2       1       1
> >
> > 25    1       2       3       2
> > 23    2       1       2       2
> > 28    3       3       1       2
> >
> > 2     1       1       2       3
> > 3     1       3       1       3
> > 1     2       1       2       3
> >
> > and i wish to extract three vectors say
> >
> >       m_1=(23,11,23)
> >
> >               m_2=(25,23,28)
> >
> >                       m_3=(2,3,1)
> >
> > or I wish to extract three matrices say
> >
> > v_1=(1,2,3\3,1,2\2,2,1)
> >
> >       v_2=(1,2,3\2,1,2\3,3,1)
> >
> >               v_3=(1,1,2\1,3,1\2,1,2)
> >
> >
> > similary if i have four groups then generated matrices or vectors
> > should be four and if i have five groups then the generated matrices
> > should be five and so on.
>
> *
> *   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/
>

--