Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Tim Scharks <tim.scharks@gmail.com> |

To |
statalist@hsphsun2.harvard.edu, martin.weiss1@gmx.de |

Subject |
Re: st: RE: RE: problem calling macros using file write in a program |

Date |
Tue, 16 Mar 2010 17:00:35 -0700 |

Martin, per your lowest, yes, should be -file close results-, my sloppy pasting from multiple files. And yes, the global specification solves it perfectly, thank you! Tim On Tue, Mar 16, 2010 at 4:24 PM, Martin Weiss <martin.weiss1@gmx.de> wrote: > > <> > > > > As soon as you use a -global-, the problem goes away: > > > ************* > clear* > cap erase OLSresults.txt > di in r _rc > > prog writeit > file open results using OLSresults.txt, write replace > file write results `"$model"' > file close results > end > > glo model Model 1. All states, no controls. > writeit > type OLSresults.txt > ************* > > See [U], 18.3. > > > HTH > Martin > > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss > Sent: Mittwoch, 17. März 2010 00:19 > To: statalist@hsphsun2.harvard.edu > Subject: st: RE: problem calling macros using file write in a program > > > <> > > That -local-, as the name somewhat implies, only exists locally, hence not > within your -program-. BTW, should it not be > > -file close results-? > > > HTH > Martin > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Tim Scharks > Sent: Dienstag, 16. März 2010 23:32 > To: statalist@hsphsun2.harvard.edu > Subject: st: problem calling macros using file write in a program > > Hi everyone, long time reader, first time asker. I would very much > appreciate any light you could shine on this problem. > > I am trying to write a short program to routinize my results output > using file write. Here is a short example of the function I am trying > to automate: > > local model "Model 1. All states, no controls." > file open results using OLSresults.txt, write replace > file write results `"`model'"' > file close test > > This works fine--my specified file has the local macro text written to > it and I know how to customize with tabs, new lines, and my regression > results. > > However, I would think that the above routine could be made even > simpler with a program that would execute from within the .do file. I > have already written a small program in this manner to add stars for > significance to my regression output using a series of if statements > with tests on the p values file write commands. Therefore I thought > this would work: > > > program define writeit > file open results using OLSresults.txt, write replace > file write results `"`model'"' > file close test > end > > local model "Model 1. All states, no controls." > writeit > > > Obviously the program would be longer with more steps to make it > useful. But even as written here executing the program writes nothing > to my file--with the replace command it wipes it clean but doesn't > write anything!?! > > Any help would be greatly appreciated. Thanks, Tim > * > * 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/ > * * 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/

**References**:**st: problem calling macros using file write in a program***From:*Tim Scharks <tim.scharks@gmail.com>

- Prev by Date:
**Re: st: problem calling macros using file write in a program** - Next by Date:
**Re: st: "moving" the var-cov matrix of estimates** - Previous by thread:
**RE: st: problem calling macros using file write in a program** - Next by thread:
**st: How to do bootstrap of candisc** - Index(es):