Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

Re: st: mata orgtype

From   Nick Cox <>
To   "" <>
Subject   Re: st: mata orgtype
Date   Tue, 23 Apr 2013 08:19:23 +0100

I don't recall seeing this varying behaviour, but then again I don't
think I have ever tried this.

I think we'd need a reproducible example to comment.

Meanwhile, the main purpose of -levelsof- was, and is, to make
analyses easier in Stata. A near equivalent in Mata is to apply
-uniqrows()- to variables read in as vectors. I'd expect that to be
faster too.


On 23 April 2013 00:29, Tomáš Houška <> wrote:

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

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index