全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
4995 3
2021-07-01
请问各位老师,stata中,命令
format  %10.2g  x
format  %10.2f   x
的含义是什么?

我运行之后发现区别是
%10.2g      .83
%10.2f     0.83

还是想请教一下g与f的含义分别是什么?

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2021-7-2 02:37:15
是周瑜 发表于 2021-7-1 21:48
请问各位老师,stata中,命令
format  %10.2g  x
format  %10.2f   x
不太会
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2021-7-2 07:35:30
请 help format,看看说明。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2021-7-2 08:14:01
查看format的帮助或者手册
可以看到例子和解释

下面就是帮助文件里面的解释和举例



The %f format

    In %w.df, w is the total output width, including sign and decimal point,
    and d is the number of digits to appear to the right of the decimal
    point.  The result is right-justified.

    The number 5.139 in %12.2f format displays as

        ----+----1--
                5.14
        

    When d==0, the decimal point is not displayed.  The number 5.14 in
    %12.0f format displays as

        ----+----1--
                   5

    %-w.df works the same way, except that the output is left-justified in
    the field.  The number 5.139 in %-12.2f displays as

        ----+----1--
        5.14



The %g format

    In %w.dg, w is the overall width, and d is usually specified as 0, which
    leaves up to the format the number of digits to be displayed to the
    right of the decimal point.  If d!=0 is specified, then not more than d
    digits will be displayed.  As with %f, a minus sign may be inserted to
    left-justify results.

    %g differs from %f in that (1) it decides how many digits to display to
    the right of the decimal point, and (2) it will switch to a %e format if
    the number is too large or too small.

    The number 5.139 in %12.0g format displays as

        ----+----1--
               5.139

    The number 5231371222.139 in %12.0g format displays as

        ----+----1--
          5231371222

    The number 52313712223.139 displays as

        ----+----1--
         5.23137e+10

    The number 0.0000029394 displays as

        ----+----1--
         2.93940e-06



The %e format

    %w.de displays numeric values in exponential format.  w records the
    width of the format.  d records the number of digits to be shown after
    the decimal place.  w should be greater than or equal to d+7 or, if
    3-digit exponents are expected, d+8.

    The number 5.139 in %12.4e format is

        ----+----1--
          5.1390e+00

    The number 5.139*10^220 is

        ----+----1--
         5.1390e+220
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群