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: AW: AW: easier way to write many matrix names


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: AW: easier way to write many matrix names
Date   Tue, 13 Jul 2010 09:16:02 +0200

<> 

Seems to work well, even though it feels clumsy:

*************
ma drop _all

forv i=1/30{
mat A`i'= matuniform(1,10)
}

forv i=1/29{
loc name `name'A`i'\
}

loc name `name'A30
di in r "`name'"
mat A=`name'
mat l A
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Martin Weiss
Gesendet: Dienstag, 13. Juli 2010 09:13
An: [email protected]
Betreff: st: AW: easier way to write many matrix names


<> 

You can certainly accumulate the command in a -local- beforehand:

*************
ma drop _all
forv i=1/29{
	loc name `name'A`i'\
}
loc name `name'A30
di in r "`name'"
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Amanda Fu
Gesendet: Dienstag, 13. Juli 2010 01:17
An: [email protected]
Betreff: st: easier way to write many matrix names

Dear statalisters,

The question I was going to ask is kind of silly---How to write the
following command in an easier way?

I would like to put all the 30 matrix (matrix named A1,A2,...,A30,
each [1 X 10]) row after row to construct a big matrix A [30 X 10]. I
used the clumsiest way---literally write out all the matrix names:

---matrix A=A1\A2\A3\A4\A5......\A25\A26\A27\A28\A29\A30---

In the middle of the above command(where ....... is located), I just
saved to type A6\...A24 to save a little bit of time.

I wondered how to write this in an easier way? I know if it is a loop,
I can use local loop ,such as --foreach matrixA of localist A1-A30---.
But this is apparently not a loop.

Any comments would be helpful. Thanks!

Sincerely,
Amanda
*
*   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/


*
*   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/


*
*   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