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: Issue with st_local


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Issue with st_local
Date   Mon, 20 Jan 2014 16:43:15 +0000

-st_local()- needs the macro name, not a macro reference. Consider
these examples.

. local answer = 42

. mata : st_local("answer")
  42

. mata : st_local("`answer'")


Nothing shown, because that reduces to

mata: st_local("42")

That could make sense:

. local 42 answer

. mata : st_local("`answer'")
  answer

In the last case, Stata interprets the macro reference as 42, which is
in turn a macro name. But in general, local macro references are
problematic within Stata, which is why -st_local()- is needed in the
first place.

Nick
[email protected]


On 20 January 2014 16:25, Amadou DIALLO <[email protected]> wrote:
> Dear Statalisters,
>
> Happy new year 2014 !
> I hope you're fine. I have the following problem in Stata. My
> st_local() command is returning nothing. What I'm I doing wrong? Many
> thanks for usual support.
>
> .    keep country product flag
>
> .
> .    so c p
>
> .    order c p f
>
> .
> .    egen ncountry = group(country)
>
> .    su nc
>
>     Variable |       Obs        Mean    Std. Dev.       Min        Max
> -------------+--------------------------------------------------------
>     ncountry |     55335         109    62.64241          1        217
>
> .    local maxcountry = r(max)
>
> .    di `maxcountry'
> 217
>
> .    mata : maxcountry = st_local("`maxcountry'")
>
> .    mata: maxcountry
>
>
> .    tomata ncountry
>
> .    mata: mycountry= colminmax(ncountry)
>
> .    mata: maxcountry = mycountry[2]
>
> .    mata: maxcountry
>   217
>
>
>
>
> --
> Amadou B. DIALLO, PhD.
> Senior Economist, AfDB.
> [email protected]
> +21671101789
> *
> *   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/


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