Stata Display
The display command prints text to the output.
Contents
Usage
display "Hello, world" // arithmetic display _N+1 // scalars display "There are " _N " cases" // stored results display "Something about `r(N)' of them" // macros display "Something about ${globals} and `locals'"
Directives
The display command also understands a set of directives that add macrotized output.
The _newline directive prints a newline character. The _newline(N) directive prints N of them.
the _continue directive suppresses the automatic newline character that follows a display command.
The _skip(N) directive moves the cursor forward N characters, effectively printing N space characters.
The _char(N) directive prints the character corresponding to ASCII or Windows-1252 codepoint N. This is useful for showing characters that would otherwise need to be escaped, or for Windows-1252 codepoints that should instead be encoded in Unicode for display.
display "Backticks look like " _char(96) display "The British Pound sign looks like " _char(163)
The _column(N) directive moves the cursor to the Nth columnar position. (Consider the start of a line to be the 1st position.) This is useful for creating columnar output, like:
display "1st 2nd 3rd" display "--- --- ---" display "1" _column(5) "11" _column(9) "111" display "999" _column(5) "99" _column(9) "9"
Styling
By default, display will print as plain text. To print with a bolded style, try:
display as result "Something about `r(N)' of them"
To print with a red color, try:
display as error "Something about `r(N)' of them"
These styles continue to be applied until a new one is set, so if using them, adjust all 'normal' display commands to display as text.