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: local variables and running do files


From   Matthew White <[email protected]>
To   [email protected]
Subject   Re: st: local variables and running do files
Date   Fri, 28 Oct 2011 14:41:27 -0400

Like Jorge suggested, you'll have to change:
sum `var'
to:
sum $var

Best,
Matt

On Fri, Oct 28, 2011 at 2:35 PM, Maria Ana Vitorino
<[email protected]> wrote:
> I tried global macros but it does not work either...
> Thanks,
> Ana
>
> . do "/var/folders/Xn/Xnl4Mq-lGR4-mNII1zm-Wk+++TI/-Tmp-//SD17268.000000"
>
> . global var "var1 var2"
>
> .
> end of do-file
>
> . do "/var/folders/Xn/Xnl4Mq-lGR4-mNII1zm-Wk+++TI/-Tmp-//SD17268.000000"
>
> . sum `var'
>
>    Variable |       Obs        Mean    Std. Dev.       Min        Max
> -------------+--------------------------------------------------------
>        var1 |        24        12.5    7.071068          1         24
>        var2 |        24        36.5    7.071068         25         48
>        var3 |        24        61.5 7.071068         50         73
>
> .
> end of do-file
>
>
> On Oct 28, 2011, at 2:31 PM, Jorge Eduardo Pérez Pérez wrote:
>
>> You can use global macros, instead of local macros. Global macros are
>> not erased when the execution of the do-file is finished.
>>
>> global var "var1 var2"
>> sum $var
>>
>> _______________________
>> Jorge Eduardo Pérez Pérez
>>
>>
>>
>>
>> On Fri, Oct 28, 2011 at 2:21 PM, Maria Ana Vitorino
>> <[email protected]> wrote:
>>>
>>> Dear statalist users,
>>> I would like to run a do file in batches (i.e. a few lines at a time)
>>> but it seems that then the local variables that I defined in the
>>> beginning do not carry over ...
>>> Any solution for this?
>>>
>>> Here is some output for a simple example so that you can better
>>> understand what is my issue.
>>>
>>> Thanks!!
>>> Ana
>>>
>>>
>>> . do "/var/folders/Xn/Xnl4Mq-lGR4-mNII1zm-Wk+++TI/-Tmp-//SD17268.000000"
>>>
>>> . sum
>>>
>>>    Variable |       Obs        Mean    Std. Dev.       Min        Max
>>> -------------+--------------------------------------------------------
>>>        var1 |        24        12.5    7.071068          1         24
>>>        var2 |        24        36.5    7.071068         25         48
>>>        var3 |        24        61.5 7.071068         50         73
>>>
>>> . local var "var1 var2"
>>>
>>> .
>>> end of do-file
>>>
>>> . do "/var/folders/Xn/Xnl4Mq-lGR4-mNII1zm-Wk+++TI/-Tmp-//SD17268.000000"
>>>
>>> . sum `var'
>>>
>>>    Variable |       Obs        Mean    Std. Dev.       Min        Max
>>> -------------+--------------------------------------------------------
>>>        var1 |        24        12.5    7.071068          1         24
>>>        var2 |        24        36.5    7.071068         25         48
>>>        var3 |        24        61.5 7.071068         50         73
>>>
>>> .
>>>
>>>
>>> *
>>> *   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/
>



-- 
Matthew White
Data Coordinator
Innovations for Poverty Action
101 Whitney Avenue, New Haven, CT 06510 USA
+1 434-305-9861
www.poverty-action.org

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index