Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: How to create a blank n x n matrix; how to refer to variables without using ID; how to extract colnames and rownames from the dataset.


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: How to create a blank n x n matrix; how to refer to variables without using ID; how to extract colnames and rownames from the dataset.
Date   Wed, 9 Mar 2011 13:07:45 +0000

Another take on this is that Mata offers a much more matrix-based view of your data. But as you're new to Stata you might want to hold off on getting into that. 

Nick 
[email protected] 

-----Original Message-----
From: Nick Cox 
Sent: 09 March 2011 13:04
To: '[email protected]'
Subject: RE: How to create a blank n x n matrix; how to refer to variables without using ID; how to extract colnames and rownames from the dataset.

Why Google when you can look at the help? That's like walking to the library to try to find a reference book when your friend the expert is next door and always available. 

Less than a hour with -help matrix- will unearth functions like J(,,). 

matrix mat1 = J(8,8,.) 

is as blank as Stata will do for you; it contains missings. 

The "first column of the dataset" is some non-Stata jargon for the first variable. 

I don't understand question 3. Columns in Stata are called variables; rows are called observations; variables have names; observations have numbers. You don't so much extract these details as mention them when necessary. 

Nick 
[email protected] 

Chen, Xianwen

I'm new to Stata and having been googling for following three
questions for more than an hour. I hope you can give me a hint.


The first question is a fast way to create a n x n matrix. For
example, to create a 8 x 8 matrix for later data manipulation. What I
now do is to create a matrix by
  matrix define mat1=vect1,vect1,vect1,vect1,vect1,vect1,vect1,vect1
where vect1 is a 8x1 matrix

Is there a better way of doing it? For example, something like
  matrix define mat1={1:8,1:8}


The second question is regarding variables. I want to search through
the variables by each entry of the data. I can specify the column IDs
but I want a more automated solution.

Is there a way of working with it, say
  somefunction{1,}
will actually refer to the first column of the dataset?


The third question is to extract colnames and rownames from the
datasets. Is there a function I can use?


I'm sorry for bombing all question all together in an email if it
doesn't fit the netiquette here. I just don't want to send three
questions in three mails, which may be annoying.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index