Differences between revisions 1 and 2
Revision 1 as of 2021-03-16 18:27:23
Size: 920
Comment:
Revision 2 as of 2021-03-16 19:55:45
Size: 2030
Comment:
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:

Alignment is controlled by the presence or absence of a negative sign (`-`) ahead of the width. A string variable formatted as `%-18s` will be left-justified; with a format of `%18s` it would have been right-justified.
Line 27: Line 30:


=== String Value Alignment ===

The `list` command automatically shifts between two output modes based on the width of the listed variables and the width of the screen.

In '''table format''', the `list` command right-justifies all string values.

In '''display format''', string values are aligned according to the display format. A string value would be left-justified if the variable had a format of `%-18s`.



=== Variable Names ===
Line 35: Line 52:
=== Value Labels ===

The `list` command also uses labels (as opposed to values) when available. To override this behavior, use the '''`nolabel`''' option.

Value labels are aligned in the same way as string values; based on the output mode and the display format. Just as a string value would be left-justified if the variable had a format of `%-18s`, a label would be justified if the variable had a format of `%-8g`.


Data Formats


Display Formats

Alignment is controlled by the presence or absence of a negative sign (-) ahead of the width. A string variable formatted as %-18s will be left-justified; with a format of %18s it would have been right-justified.


list

The list command examines data to (re-)allocate text width. If the longest value for a string variable with format %18s is 12 characters long, then list will only allocate 12 columns for that variable. This behavior can be disabled using the nocompress option.

Note that the default behavior has an impact on performance, especially for large datasets. As such, there is a fast option which is simply an alias for nocompress.

To truncate string values specifically, use the string option.

list comment, string(10)

String Value Alignment

The list command automatically shifts between two output modes based on the width of the listed variables and the width of the screen.

In table format, the list command right-justifies all string values.

In display format, string values are aligned according to the display format. A string value would be left-justified if the variable had a format of %-18s.

Variable Names

The list command also abbreviates variable names (defaulting to 8 characters). To increase that character limit, use the abbreviate option.

list very_long_variable_name, abbreviate(50)

Value Labels

The list command also uses labels (as opposed to values) when available. To override this behavior, use the nolabel option.

Value labels are aligned in the same way as string values; based on the output mode and the display format. Just as a string value would be left-justified if the variable had a format of %-18s, a label would be justified if the variable had a format of %-8g.


CategoryRicottone

Stata/DataFormats (last edited 2025-03-05 02:10:25 by DominicRicottone)