Statalist


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

Re: st: saving local macros


From   "Ashim Kapoor" <[email protected]>
To   [email protected]
Subject   Re: st: saving local macros
Date   Thu, 8 Jan 2009 10:26:47 +0530

okay Jeff, Thank you. I have to try this out.

Ashim.

On Thu, Jan 8, 2009 at 1:38 AM, Jeph Herrin <[email protected]> wrote:
>
> I posted this earlier, but it didn't seem to go through. Here
> again
>
> ...
>
> Here's a code which creates a do-file which will reassign all
> the local macros. The only thing that needs to be fixed is that
> it should have embedded quotes and as usual I can't seem to get
> them right and I am off for lunch etc now.
>
> * ----------- for testing
>
> local test "This one"
>
> *------------- save locals ------------------
> capture log close
> log using mylocals.txt, text replace
> macro list
> log close
> file open logfile using mylocals.txt, read
> file open mylocals using mylocals.do, replace write
> file read logfile line
> while r(eof)==0 {
>    local lname : word 1 of "`line'"
>    if strpos("`lname'","_")==1 {
>        local lval  : subinstr local line "`lname'" ""
>        local lname : subinstr local lname "_" ""
>        local lname : subinstr local lname ":" ""
>    * next line should have embedded quotes for last token
>        file write mylocals "local `lname' `lval'"  _n
>    }
>    file read logfile line
> }
> file close logfile
> file close mylocals
> *----------- done --------------------------
>
>
> This creates a do-file called mylocals.do; if you -include-
> it, it will reload all the local macros that you had when you
> ran it.
>
> hope this helps,
> Jeph
>
> Ashim Kapoor wrote:
>>
>> Hello everyone,
>>
>> I wish to do the following : -
>>
>> stata code
>> .....
>> .....
>> save dataset,replace
>> save list_of_local_macros
>> ...
>> ...
>>
>> I wish to do this as it makes it easier to debug a code, cos then I
>> can use the dataset and the list of macros and run a small program on
>> the output only from that point in the code.
>>
>> Is there a way to save local macros ?
>>
>> Thank you,
>> Ashim.
>> *
>> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index