Stata: Hiding the command line

. 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.

+4
source share
3 answers

Try the following: 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 } 
+5
source

The answer from user1493368 is correct, but such code is tedious and error prone for more complex examples. Another answer is just to learn how to write Stata programs! Put this in the 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 enter interactively

 myprog 

As in practice, you make a lot of small mistakes, the very first line, for example

 capture program drop myprog 

- a good idea.

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

+9
source

Commenting out Stata output, especially when you want to share your log files, becomes a problem that is very well reflected in your question.

As Nick Cox perfectly explained, Writing a program to display text is a very good idea. However, the inclusion of text in the program is due to the fact that you cannot use this program with other variables. For example, if you are writing a program to run a regression with given variables, you cannot use this program with other variables if you comment on the results. In other words, writing comments on specific results will make the program less useful. As a result, you will finish writing a program for each analysis, which is not so attractive.

So what is my suggestion? Use MarkDoc pakcage to comment on your results.

In MarkDoc (ssc install markdoc) you can write comments using Markdown / HTML / LaTeX and export it to a dynamic document in Stata. In your example, this will be as follows:

  qui log using example, replace sysuse auto, clear /*** Writing comments in Stata logfiles ================================== I am getting some summary statistics for PRICE ***/ summarize price qui log c markdoc example, replace export(pdf) 

And MarkDoc will create a PDF for you that interprets your comments as Markdown. In addition to pdf, you can convert the same log file to other formats such as docx , html , tex , Open Office odt , slide , as well as epub .

PDF and HTML formats will also have a syntactic marker for Stata commands using Statax Syntax Highlighter .

+4
source

All Articles