Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Writing macro contents to a file


From   Roger Newson <roger.newson@kcl.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: Writing macro contents to a file
Date   Wed, 25 Jun 2003 22:15:56 +0100

Thanks to Jeff Pitblado for this solution. And thanks to all at StataCorp for giving us the -macval()- function. It will make life much easier for users of the -file- package.

Best wishes

Roger

At 12:43 25/06/03 -0500, Jeff Pitblado wrote:


I believe -macval()- will solve the problem.  The second -file write- command
below uses -macval()- to output the contents of -`linecur'- to the file.

***** BEGIN:
. tempname uhandle

. local linecur "\textit{Make}&\textit{Weight}\\\\"

. mac li _linecur
_linecur:       \textit{Make}&\textit{Weight}\\

. file open `uhandle' using nutz.txt, write text replace

. file write `uhandle'  `"`linecur'"' _n

. file write `uhandle'  `"`macval(linecur)'"' _n

. file close `uhandle'

. type nutz.txt
\textit{Make}&\textit{Weight}\
\textit{Make}&\textit{Weight}\\

***** END:

--Jeff
jpitblado@stata.com
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
  or 020 7848 6605 International +44 20 7848 6605
Email: roger.newson@kcl.ac.uk
Website: http://www.kcl-phs.org.uk/rogernewson

Opinions expressed are those of the author, not the institution.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index