Quietly and Noisily | Suppress the output in Stata

The purpose of quietly command is to suppress results, such as when you prefer not to display results or tables in Stata’s output window. To explain it, we will use the Stata sample data, which can be accessed by using the below command:

sysuse auto.dta, clear

The data contain the following variables:

Quietly

Suppose you want to see the regression results or tables on Stata output window, then you will use the quietly prefix with the regress command (or any other command) in the Stata as shown below: (Note: it is not necessary to put “:” after the quietly prefix)

quietly: regress price mpg                                                                                                                                          
quietly regress price mpg

When you run this command, the output will look like this:

Let’s use the replace command without and with the quietly prefix for better understanding. Firstly, we will run without the quietly. The command and results are given below:

replace weight = 1

You will see that under the command, it has been shown that 74 real changes have been made. Now let’s try it with the quietly command as shown below:

quietly replace weight = 1

The changes have been made, but we cannot see how many observations have changed or what the output was, so this quietly command suppresses the output of the command.

We can use the quietly prefix with multiple commands using the block code as shown below. Insert of writing the quietly prefix with each command separately, we will write it once.

quietly {                                                                                                                                                                                   
 regress price mpg                                                                                                                                                                
 summarize price mpg                                                                                                                                                           
 }          

Noisily

Noisily is the opposite command of quietly. When using the quietly prefix for a block containing multiple commands in Stata, but you want one of those commands to display its output, you can use the noisily prefix for that specific command.

The command is shown below:

quietly {                                                                                                                                                                                  
regress price mpg                                                                                                                                                            
summarize price mpg                                                                                                                                                         
regress mpg price                                                                                                                                                               
noisily: summarize price mpg weight                                                                                                                                                
}   

So, in the above command, we want all the commands to be run quietly but want to display the summary command results. In that case, the noisily prefix has been used with the summarize command.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Tweet
Share
Share
Pin