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]

SOLVED - Re: st: Why won't my -local- work?


From   Brandon Olszewski <[email protected]>
To   [email protected]
Subject   SOLVED - Re: st: Why won't my -local- work?
Date   Fri, 22 Feb 2013 16:31:50 -0800

That was it! Thanks, Phil.
I was running all out of the same .do window, but in a piecemeal
fashion. I didn't realize you have to run the whole block (including
macro assignment, cleaning, and reg, for instance) in one shot. When I
do that, it works.
Thanks!

On Fri, Feb 22, 2013 at 4:10 PM, Phil Clayton
<[email protected]> wrote:
> Are you using the macro in the same program (or do-file) as it was defined? If you define it in one program it will not be defined in a different program (hence the term "local").
>
> Example:
>
> ------------------------------------
> program define myprog
>         display "mymacro: `mymacro'"
> end
>
> local mymacro 1 2 3
> display "mymacro: `mymacro'"
> myprog
> ------------------------------------
>
> Phil
>
> On 23/02/2013, at 11:01 AM, "[email protected]" <[email protected]> wrote:
>
>> I'm mytified, too.
>> Are you spelling the macroname consistently?
>>
>> Sent with Verizon Mobile Email
>>
>>
>> ---Original Message---
>> From: [email protected]
>> Sent: 2/22/2013 6:44 pm
>> To: [email protected]
>> Subject: Re: st: Why won't my -local- work?
>>
>> Thanks for the idea, David. But it returned the same result. With quotes, and
>>> disp "`mymacro'"
>> I still return nothing but a blank line. I am mystified why Stata
>> isn't storing my varlist, which I don't think should require (double)
>> quotes as a string would.
>> Do I have to, for instance, "turn macro on" the way I can "set more off"?
>>
>>
>> On Fri, Feb 22, 2013 at 3:37 PM, [email protected] <[email protected]> wrote:
>>> Put quotes around the macro value.
>>> local mymacro "var1 var2 var3"
>>>
>>> Also check the value by...
>>> disp "`mymacro'"
>>>
>>> hth
>>> david
>>>
>>> Sent with Verizon Mobile Email
>>>
>>>
>>> ---Original Message---
>>> From: [email protected]
>>> Sent: 2/22/2013 6:31 pm
>>> To: [email protected]
>>> Subject: st: Why won't my -local- work?
>>>
>>> I want to make some tables using -contract- and -collapse- for about
>>> thirty variables. I figured a local macro to identify that varlist
>>> would be the best way to do it. I followed examples I've seen
>>> elsewhere - such as http://!
>> www.ssc.wisc.edu/sscc/pubs/stata_prog1.htm
>>> - and on Statalist but keep failing. Here is an example of my syntax:
>>>
>>>> local mymacro var1 var2 var3
>>>
>>> When I try and do anything with mymacro, I get no results returned.
>>> For instance,
>>>> sum `mymacro'
>>> gives me sum output of all vars.
>>>> keep `mymacro'
>>> gives me the error "varlist or in range required". When I try
>>>> reg outcome `mymacro'
>>> all I get is a constant value in my reg output. I want to replace
>>> contents of that varlist with dummies, such that
>>>> foreach var of local mymacro {
>>>>    replace `var'=1 if `var'!=0
>>>>    }
>>> But obviously, that doesn't work either, because for some reason,
>>> nothing seems to be stored in my macro.
>>>
>>> I am running Stata 12. Thanks for any help.
>>>
>>> Brandon Olszewski
>>> *
>>> *   For searches and help t!
>>> ry:
>>> *   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/
>> *
>> *   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/
>
>
> *
> *   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