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