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: dynamic line execution in mata


From   Andrew Maurer <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: dynamic line execution in mata
Date   Mon, 10 Feb 2014 17:38:26 +0000

Hi Statalist,

I am trying to find Mata's equivalent of Stata's macro expansion functionality. In the below example, I first define an object thisvar as the string "date" and I define the object date as the column vector 1 \ 2 \ 3 \ 4 \ 5. How can I return the contents of the "date" object by only referencing "thisvar"? 

In the line, rows( thisvar ), thisvar is simply the 1x1 matrix containing the string "date", so rows( thisvar ) returns: 1. What I am looking for is something like rows( `=thisvar' ), so as to return 5 rather than 1.

********* begin example *********

mata

i = 1
date = 1 \ 2 \ 3 \ 4 \ 5
varnames = "date", "price"
thisvar = varnames[1,i]
rows( thisvar ) // output: 1
rows( date ) // output: 5

end

********* end example ***********

Thank you,
Andrew Maurer


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


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