Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stata: Hiding command lines

Tags:

stata

. sysuse auto, clear
(1978 Automobile Data)

. di "I am getting some summary statistics for PRICE"
I am getting some summary statistics for PRICE

. su price

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       price |        74    6165.257    2949.496       3291      15906

. 
end of do-file

I want to hide the command lines, and show only the results as follows:

I am getting some summary statistics for PRICE

        Variable |       Obs        Mean    Std. Dev.       Min        Max
    -------------+--------------------------------------------------------
           price |        74    6165.257    2949.496       3291      15906

How can I do this? Thanks.

like image 800
Bill TP Avatar asked Mar 26 '13 16:03

Bill TP


People also ask

How do I get the Command window back in Stata?

You can also use Mission Control to reveal hidden windows, or use Command–` (left quote) to cycle through all open Stata windows. Many of Stata's windows have functionality that can be accessed by clicking on the right mouse button (right-clicking) within the window.

What is quietly Command in Stata?

quietly suppresses all terminal output for the duration of command. It is useful both interactively and in programs. noisily turns back on terminal output, if appropriate, for the duration of command. It is useful only in programs.

What is the display Command in Stata?

display displays strings and values of scalar expressions. display produces output from the programs that you write. Interactively, display can be used as a substitute for a hand calculator; see [R] display. You can type things such as display 2+2.

What is review window in Stata?

The Review window keeps a record of all commands Stata has run, both successful and unsuccessful. This can help you keep track of what you have done. You can copy and paste commands to this window, and can also re-run commands from this window.


2 Answers

The answer from user1493368 is correct, but writing code like that is tedious and error-prone for more complicated examples. Another answer is just to learn how to write Stata programs! Put this in a do-file editor window and run it

program myprog 
    qui sysuse auto, clear
    di "I am getting some summary statistics for PRICE"
    su price
end 

Then type interactively

myprog 

As in practice one makes lots of little mistakes, a very first line such as

capture program drop myprog 

is a good idea.

This really is prominently and well documented: start with the later chapters in [U].

like image 147
Nick Cox Avatar answered Oct 28 '22 09:10

Nick Cox


Try this: The output text file (quiet_noise. txt) will have the one you want.

quietly {
     log using quiet_noise.log, text replace
     sysuse auto
     noisily: di "I am getting some summary statistics for PRICE"
     noisily: su price
     log close
}
like image 27
Metrics Avatar answered Oct 28 '22 09:10

Metrics