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: Re: st: Words surrounded with single quotes in a local macro


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: Re: st: Words surrounded with single quotes in a local macro
Date   Wed, 15 Jan 2014 13:22:49 +0000

Check on

temp2

versus

tempo2

You may be using different names in different parts of your code.  In
both of your posts you have mentioned them as if they were the same.

Quite different issue: Local macros are only visible within the same
"locale", i.e. the same interactive session, program, do-file,
(highlighted) do-file editor contents.

Nick
[email protected]


On 15 January 2014 13:08, Tomas Lind <[email protected]> wrote:
> After having created locals temp and temp2 I display them.
> The first local, temp, show the names I have excepted.
>
> di "`tempo'"
> tf1 tf2 tf3 tf4 tf5 tf6 tf7 tf8
>
> However, Stata doesn´t return anything for temp2
>
> di "`tempo2'"
>
>
> When Stata executes the append-statement, I get an error message:
>
> append using "`tempo2'"
> file  not found
>
>
> /Tomas
>
>
>
> [email protected] skrev: -----
> Till: "[email protected]" <[email protected]>
> Från: Nick Cox
> Sänt av: [email protected]
> Datum: 2014-01-15 13:52
> Ärende: Re: st: Words surrounded with single quotes in a local macro
>
> You can help yourself debug this by showing us the value of `tempo2'
> and explaining what "Do[es] NOT Work" means precisely.
>
> Nick
> [email protected]
>
>
> On 15 January 2014 12:30, Tomas Lind <[email protected]> wrote:
>> Hi all,
>>
>> I´m setting up number of tempfiles named tf1, tf2, tf3 . . .  .
>>
>> First I create the names and put them into a macro called tempo.  That works fine.
>>
>> The problem is with the second makro, temp2, where I try to store the names `tf1&#8217;  `tf2&#8217;  `tf3&#8217; . . . enclosed in quotes to be able to use them in an append statement.
>>
>> I want the append statement to look like this:
>> append `tf1' `tf2' `tf3' . . .
>>
>>
>> forvalues  i = 1/`Number'  {            // This many tempfiles
>> local  tempo   `tempo'    tf`i'    //  named  tf1, tf2, tf3 . . . okey
>> local  tempo2  `tempo2'  `"`tf`i''"'    // `tf1&#8217;  `tf2&#8217;  `tf3&#8217; . . .  Do NOT work
>> }
>>
>> tempfile `tempo'                              // works fine
>>
>>
>> Loop that runs several regressions and store
>> each result in a tempfile
>>
>>
>> append using "`tempo2'"              // Do NOT work
>>
>>
>>
>>
>> Anyone have a solution on this?
>>
>> I´m running Stata 13.1 on a PC
>>
>> Yours
>> Tomas
>> *
>> *   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