Statalist


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

Re: st: saving local macros


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: saving local macros
Date   Thu, 08 Jan 2009 08:54:04 -0500


Ashim Kapoor wrote:
okay Jeff, Thank you. I have to try this out.

Ashim.


here, I fixed the problem:

*------------- save locals ------------------
capture log close
log using mylocals.txt, text replace
macro list
log close
file open logfile using mylocals.txt, text read
file open mylocals using mylocals.do, text 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 lval=trim("`lval'")
		local lname : subinstr local lname "_" ""
		local lname : subinstr local lname ":" ""
		file write mylocals "local `lname' " _char(34) "`lval'" _char(34)  _n
	}
	file read logfile line
}
file close logfile
file close mylocals
*----------- done --------------------------

good luck,
Jeph
*
*   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