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: mata orgtype
From
Tomáš Houška <[email protected]>
To
[email protected]
Subject
st: mata orgtype
Date
Tue, 23 Apr 2013 01:29:45 +0200
Dear Statalist,
I have a Stata macro generated by -levelsof- and I am trying to parse
it in mata with -tokens- so that I can run mata loops with it...
example:
levelsof product, local(product_id)
mata
prods=tokens(st_local("product_id"))
for(i = 1; i<=length(prods); i++) {
... commands including prods[i] ...
}
end
My problem is that on some types of variables, the resulting mata item
(in this case "prods") is a row vector, but sometimes it is a scalar
string. Once it is a scalar string, I cannot refer to items on
individual positions by -prods[i]- as I can do when it is a row
vector.
Is there a rule to which type gets created and when? Or is there a way
to make sure that row vector gets created?
Thank you
Tomas
*
* 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/