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
Wed, 25 Sep 2013 13:17:04 +0100
Good point. An alternative, which I favour personally, is to pass "`:
sortedby'" from Stata to Mata as an argument to your Mata function.
That can always be automated, I think.
Nick
[email protected]
On 24 September 2013 20:35, Phil Schumm <[email protected]> wrote:
> On Sep 24, 2013, at 1:46 PM, Nick Cox <[email protected]> wrote:
>> . mata :
>> : which = "foreign"
>> : which == sprintf("`: sortedby'")
>
>
> This will work interactively, but not in a function, since the expansion will occur at compile time instead of runtime. Alternatives that work inside a function include:
>
> printf(st_macroexpand("`" + ":sortedby" + "'"))
>
> or
>
> stata("des, varl", 1)
> printf(st_global("r(sortlist)"))
>
> and possibly others that I don't know about. Seems odd that the current sort order is not available via c()...
>
>
> -- Phil
>
>
> *
> * 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/
*
* 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/