📄 format.hlp
字号:
{smcl}
{* 16mar2005}{...}
{cmd:help format}, {cmd:help set dp}{right:dialog: {bf:{dialog format}}}
{hline}
{title:Title}
{p2colset 5 19 21 2}{...}
{p2col :{hi:[D] format} {hline 2}}Specify variable display format{p_end}
{p2colreset}{...}
{title:Syntax}
{phang}
Specify display format for variables
{p 8 15 2}
{opt form:at} {varlist} {cmd:%}{it:fmt}
{p 8 15 2}
{opt form:at} {cmd:%}{it:fmt} {it:varlist}
{phang}
Set decimal symbol
{p 8 15 2}
{opt se:t} {opt dp} {c -(}{opt com:ma}|{opt per:iod}{c )-}
[{cmd:,} {opt perm:anently}]
where {cmd:%}{it:fmt} is
{p 8 23 2}{cmd:%}{it:fmt} {space 7} description {space 27} example{p_end}
{hline}
Right-justified formats
{p 8 23 2}{cmd:%}{it:#}{cmd:.}{it:#}{cmd:g} {space 6} general numeric
format {space 16} {cmd:%9.0g}{p_end}
{p 8 23 2}{cmd:%}{it:#}{cmd:.}{it:#}{cmd:f} {space 6} fixed numeric
format {space 18} {cmd:%9.2f}{p_end}
{p 8 23 2}{cmd:%}{it:#}{cmd:.}{it:#}{cmd:e} {space 6} exponential numeric
format {space 12} {cmd:%10.7e}{p_end}
{p 8 23 2}{cmd:%d} {space 9} default numeric elapsed date
format {space 3} {cmd:%d}{p_end}
{p 8 23 2}{cmd:%d}{it:...} {space 6} user-specified elapsed date
format {space 4} {cmd:%dM/D/Y}{p_end}
{p 8 23 2}{cmd:%}{it:#}{cmd:s} {space 8} string
format {space 25} {cmd:%15s}{p_end}
Right-justified, comma formats
{p 8 23 2}{cmd:%}{it:#}{cmd:.}{it:#}{cmd:gc} {space 5} general numeric
format {space 16} {cmd:%9.0gc}{p_end}
{p 8 23 2}{cmd:%}{it:#}{cmd:.}{it:#}{cmd:fc} {space 5} fixed numeric
format {space 18} {cmd:%9.2fc}{p_end}
Leading-zero formats
{p 8 23 2}{cmd:%0}{it:#}{cmd:.}{it:#}{cmd:f} {space 5} fixed numeric
format {space 18} {cmd:%09.2f}{p_end}
{p 8 23 2}{cmd:%0}{it:#}{cmd:s} {space 7} string
format {space 25} {cmd:%015s}{p_end}
Left-justified formats
{p 8 23 2}{cmd:%-}{it:#}{cmd:.}{it:#}{cmd:g} {space 5} general numeric
format {space 16} {cmd:%-9.0g}{p_end}
{p 8 23 2}{cmd:%-}{it:#}{cmd:.}{it:#}{cmd:f} {space 5} fixed numeric
format {space 18} {cmd:%-9.2f}{p_end}
{p 8 23 2}{cmd:%-}{it:#}{cmd:.}{it:#}{cmd:e} {space 5} exponential numeric
format {space 12} {cmd:%-10.7e}{p_end}
{p 8 23 2}{cmd:%-d} {space 8} default numeric elapsed date
format {space 3} {cmd:%-d}{p_end}
{p 8 23 2}{cmd:%-d}{it:...} {space 5} user-specified elapsed date
format {space 4} {cmd:%-dM/D/Y}{p_end}
{p 8 23 2}{cmd:%-}{it:#}{cmd:s} {space 7} string
format {space 25} {cmd:%-15s}{p_end}
Left-justified, comma formats
{p 8 23 2}{cmd:%-}{it:#}{cmd:.}{it:#}{cmd:gc} {space 4} general numeric
format {space 16} {cmd:%-9.0gc}{p_end}
{p 8 23 2}{cmd:%-}{it:#}{cmd:.}{it:#}{cmd:fc} {space 4} fixed numeric
format {space 18} {cmd:%-9.2fc}{p_end}
Centered formats
{p 8 23 2}{cmd:%~}{it:#}{cmd:s} {space 7} string format
(special) {space 15} {cmd:%~15s}{p_end}
{hline}
{p 4 6 2}See {help dfmt} for a description of the {cmd:%d} date
format.{p_end}
{p 4 6 2}See {help tfmt} for a description of the {cmd:%t} time-series
format.{p_end}
{p 4 6 2}The centered format {cmd:%~}{it:#}{cmd:s} is for use with
{help display} only.{p_end}
{p 4 6 2}Specifying a format having more than 26 digits may result in Stata
using a truncated display format.{p_end}
{p 4 6 2}Replacing {it:#}{cmd:.}{it:#} in the table above with
{it:#}{cmd:,}{it:#} specifies that the European decimal symbol (the comma) be
used instead of the default.
{title:Description}
{pstd}
{opt format} allows you to specify the display format for variables. The
internal precision of the variables is unaffected.
{pstd}
{opt set dp} lets you globally set the symbol Stata uses to represent the
decimal symbol. The default is {opt period}, meaning that one and a half is
displayed as 1.5; {opt comma} specifies that it be displayed as 1,5.
{title:Option}
{phang}
{opt permanently} specifies that, in addition to making the change right now,
the {opt dp} setting be remembered and become the default
setting when you invoke Stata.
{title:Examples}
{cmd:. format cost %9.2f}
{cmd:. format age %9.0g}
{cmd:. format name %20s}
{cmd:. format hiredate %d}
{cmd:. format hiredate %dD/M/CY}
{title:Also see}
{psee}
Manual: {bf:[D] format}
{psee}
Online: {help dates}, {helpb display}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -