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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Re lincom not recognising macros


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re lincom not recognising macros
Date   Tue, 26 Jun 2012 12:37:06 +0100

If you want to automate this, you may well end up using local macros.
Efficiency is not really an issue; the time or memory cost of using a
local macro is trivial, and there may be no other solution. Further
advice would depend on more information about where the numbers come
from.

Either way, using a variable (Stata sense) to hold a constant is not
regarded as a use of macros. See also
http://www.stata.com/statalist/archive/2008-08/msg01258.html

Nick

On Tue, Jun 26, 2012 at 11:46 AM, Jennifer Dent <JDent@sgul.ac.uk> wrote:
> Dear Nick
>
> Apologies for the typos.
>
> Re using the 'indirect' solution - I want to run the function several times
> over several different datasets, within which the values of the (local)
> variables will change slightly. I'll have a think about which is more
> efficient, given the solution.
>
> Thank you for your help,
>
> Jennifer
>
>
> On 26/06/2012 11:21, Nick Cox wrote:
>>
>> There are no macros (marcos, macors) here.
>>
>> What you may be seeking is
>>
>> local var1_prop =  0.46
>> local var2_prop = 0.54
>>
>> lincom _b[_cons] + _b[indep1]*`var1_prop' + _b[indepvar2]*`var2_prop'
>>
>> although I don't see why you would prefer that to your direct
>> solution, which as you say does work.
>>
>> Nick
>>
>> On Tue, Jun 26, 2012 at 11:11 AM, Jennifer Dent<JDent@sgul.ac.uk>  wrote:
>>
>>> I'm trying to run lincom in stata 12 but I am having trouble when I use a
>>> marco name, rather than a number.
>>>
>>> This is what I have:
>>>
>>> gen var1_prop =  0.46
>>> gen var2_prop = 0.54
>>> xi:xtmixed depvar indep1 indep2 || randomeffect
>>> lincom _b[_cons] + _b[indep1]*var1_prop + _b[indepvar2]*var2_prop
>>>
>>> Error: var1_prop not found
>>>
>>> If I replace var1_prop and var2_prop with the actual numbers (i.e. lincom
>>> _b[_cons] + _b[indep1]*0.46 + _b[indepvar2]*0.54), then stata is happy.
>>> Is
>>> there a way to force lincom to recognise my numeric macors by name,
>>> rather
>>> than to have to find and replace the names with numbers?
>>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/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/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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