|
Size: 694
Comment:
|
← Revision 10 as of 2025-10-24 17:27:01 ⇥
Size: 1154
Comment: Rewrite
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| = Stata Logs = | = Stata Log = |
| Line 3: | Line 3: |
| Stata outputs to a terminal emulator. Output can be recorded into a markup file, which can be rendered into file formats including raw text. | '''`-log-`''' wraps logging facilities. |
| Line 9: | Line 9: |
| == Basic Logging == | == Usage == |
| Line 12: | Line 12: |
| log using "path/to/file", replace | log using "path/to/file" log close }}} |
| Line 14: | Line 16: |
| // do something | Stata's rich log format uses the `.smcl` file extension. |
| Line 16: | Line 18: |
| If the '''`text`''' option is specified, or if the file extension is one of `.log` or `.txt`, then a plaintext log will instead be created. === Temporarily Disabling Logging === Some output should not be recorded. Try: {{{ |
|
| Line 17: | Line 28: |
| di "Rather than running commands `quietly`, temporarily turn off logging. | display "Rather than running commands quietly, temporarily turn off logging. |
| Line 19: | Line 30: |
// do something else log close translate "path/to/file.smcl" "path/to/file.log" |
|
| Line 30: | Line 36: |
| == Listing == | == Stored Results == |
| Line 32: | Line 38: |
| The `list` command abbreviates variables and applies formats to data. To override the default abbreviation limit of 8 characters, use: | `-log-` stores the following details: |
| Line 34: | Line 40: |
| {{{ list very_long_variable_name, abbrev(50) }}} |
* log name in `r(name)` * log filename in `r(filename)` * logging status (on or off) in `r(status)` * log type (smcl or text) in `r(type)` `log query _all` stores the number of open logs in `r(numlogs)`. For each open log, it stores the above details as e.g. `r(name1)`, `r(name2)`, and so on. ---- == See also == [[https://www.stata.com/manuals/rlog.pdf|Stata manual for -log-]] [[https://www.stata.com/manuals/u15.pdf|Stata manual chapter 15: Saving and printing output-log files]] |
Stata Log
-log- wraps logging facilities.
Usage
log using "path/to/file" log close
Stata's rich log format uses the .smcl file extension.
If the text option is specified, or if the file extension is one of .log or .txt, then a plaintext log will instead be created.
Temporarily Disabling Logging
Some output should not be recorded. Try:
log off display "Rather than running commands quietly, temporarily turn off logging. log on
Stored Results
-log- stores the following details:
log name in r(name)
log filename in r(filename)
logging status (on or off) in r(status)
log type (smcl or text) in r(type)
log query _all stores the number of open logs in r(numlogs). For each open log, it stores the above details as e.g. r(name1), r(name2), and so on.
See also
Stata manual chapter 15: Saving and printing output-log files
