楼主: 是周瑜
3621 3

[数据管理求助] stata中数据格式 %10.2g 与 %10.2f 的区别 [推广有奖]

  • 0关注
  • 0粉丝

大专生

53%

还不是VIP/贵宾

-

威望
0
论坛币
34284 个
通用积分
15.6985
学术水平
3 点
热心指数
3 点
信用等级
3 点
经验
2346 点
帖子
29
精华
0
在线时间
67 小时
注册时间
2019-9-27
最后登录
2021-12-27

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问各位老师,stata中,命令
format  %10.2g  x
format  %10.2f   x
的含义是什么?

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

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

二维码

扫码加我 拉你入群

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

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

关键词:Stata 数据格式 tata format FORMA

沙发
李璇璇 发表于 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

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-2 20:06