Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Extracting Matrices from dataset


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Extracting Matrices from dataset
Date   Mon, 20 Aug 2007 13:36:10 +0100

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 
right for your problem. 

Nick 
n.j.cox@durham.ac.uk 

Nadeem Shafique
 
> 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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index