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]

Re: st: how to access Stata's record of the variable data is sorted on


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: how to access Stata's record of the variable data is sorted on
Date   Tue, 24 Sep 2013 19:46:42 +0100

It's not a local macro. If it were a local macro, it could be not
visible everywhere. It's an extended macro function.

The use of the `: ' syntax to evaluate it is to be thought of as
similar to, but certainly not identical.

For some technique, consider

. sysuse auto, clear
(1978 Automobile Data)

. di "`: sortedby'"
foreign

. mata :
------------------------------------------------- mata (type end to
exit) --------------
: which = "foreign"

: which == sprintf("`: sortedby'")
  1

: end

Nick
[email protected]


On 24 September 2013 19:12, László Sándor <[email protected]> wrote:
> Thanks!
>
> I cannot get it working in Mata though. st_local(":sorted by") returns
> an empty string, while the local is accessed fine in Stata. What is
> the way around this? (And why does this happen, by the way?)
>
> On Mon, Sep 23, 2013 at 1:24 PM, Robert Picard <[email protected]> wrote:
>> dis "`:sortedby'"
>>
>> On Mon, Sep 23, 2013 at 12:52 PM, László Sándor <[email protected]> wrote:
>>> Hi,
>>> [D] sort documents how Stata keeps track of the variable the data has
>>> been sorted on, and you see this information as the last line of the
>>> output from -describe-. However, I cannot find a way to access this
>>> information and make use of it. Is there any?
>>>
>>> For those interested, I think I have a legitimate use case when I want
>>> to use this. Sorting my data can take a long-long time, even if the
>>> variable is categorical. But as I need a -tab- of the categories
>>> anyway, I can utilize the frequencies returned to assign a rank for a
>>> new sort order for -mf_collate-. This should be much faster. But I
>>> would be happy to skip this step completely if the data is already
>>> sorted on the variable when my command is invoked.

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