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

Re: st: RE: save output


From   Philip Greenwood <[email protected]>
To   [email protected]
Subject   Re: st: RE: save output
Date   Fri, 23 Aug 2002 10:58:08 +1000

Thanks for your response Nick,

>> I'm wondering if there is a way save the entire output of
>> any given command to, say, a macro.
>>
>> (I am writing an ado file that runs commands on multiple
>> datasets and would like to be able to suppress output as in
>> -quietly-, but then re-display it with a message that is
>> particular to each dataset - but only if the given command
>> produces an output!)
>
> You could accumulate output as a long string of characters
> in a macro, punctuated by SMCL directives. The limits are
> documented under -help limits-.
>
> Alternatively, you could route output using -file- as lines of
> text to a file and -type- that only under certain conditions.
> Again, SMCL directives would make that most attractive.
>
> Without knowing more about your problem, however,
> I suspect that there are more direct ways to tackle this.


Maybe the best way to elucidate the problem is to give a little example.
My command is called -mido-.

Typing:

- mido recode var1 1=2 -

displays:

->  dataset = _mitemp1.dta
(1077 changes made)
->  dataset = _mitemp2.dta
(1077 changes made)
->  dataset = _mitemp3.dta
(1077 changes made)
->  dataset = _mitemp4.dta
(1077 changes made)
->  dataset = _mitemp5.dta
(1077 changes made)

whereas typing:

- mido generate sex=1 -

currently displays:

->  dataset = _mitemp1.dta
->  dataset = _mitemp2.dta
->  dataset = _mitemp3.dta
->  dataset = _mitemp4.dta
->  dataset = _mitemp5.dta


The terminal output in the -recode- case is fine. However the -generate- output is a little odd. -generate- doesn't normally display anything and I would prefer it if -mido generate..- also didn't produce any terminal output.

I thought that if could suppress the terminal output and save it to a macro, then i could test to see if it's non-empty and only then display it with the "dataset =..".

Nick's first idea of accumulating the output as a long string of characters in a macro might then achieve this - but I don't know how it's done.

Thanks,
Philip

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index