全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 悬赏大厅
3309 8
2017-07-31
悬赏 10 个论坛币 未解决
这是stata11的数据,读入之后,怎么都没法变成数值型,不管是用real,还是 destring,都提示有nonnu的数据,但是我检查了,没有。用real, 后面加了force。结果全部变成...了。求助。

股票代码.dta

大小:51.07 MB

 马上下载

stata11的

二维码

扫码加我 拉你入群

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

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

全部回复
2017-7-31 13:42:39
destring, replace
这个试过了吗?
二维码

扫码加我 拉你入群

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

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

2017-7-31 13:53:47
试过了,还是提示有非数字
二维码

扫码加我 拉你入群

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

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

2017-7-31 19:43:45
The most common cause of this error message is that you are trying to use a string variable with a command that only supports numeric variables. You can only tell the type of a variable by using the describe command.
This is easy to fix.
If you have a string variable and want to convert it to a numeric variable, you can use the encode command. If you have a string variable that has only numbers in it, then you can alternatively use the real() function.
. describe
   
Contains data
   obs:             4                          
  vars:             2                          
  size:            48
------------------------------------------------------------------------
                      storage  display     value
variable name   type   format      label      variable label
------------------------------------------------------------------------
a                    str4    %9s                  
b                    str4   %9s                    
------------------------------------------------------------------------
Sorted by:  
      Note:  dataset has changed since last saved

. list

      +-------+
      | a   b |
      |-------|
   1. | 1   a |
   2. | 2   b |
   3. | 3   c |
   4. | 4   d |
      +-------+

. gen na = real(a)
. encode b, gen(nb)
. describe
        
Contains data
   obs:             4                          
  vars:             4                          
  size:            80
------------------------------------------------------------------------
                   storage  display       value
variable name   type   format      label      variable label
------------------------------------------------------------------------
a               str4   %9s                    
b               str4   %9s                    
na              float  %9.0g                  
nb              long   %8.0g       nb         
------------------------------------------------------------------------
Sorted by:  
      Note:  dataset has changed since last saved

. list
      +-----------------+
      | a   b   na   nb |
      |-----------------|
   1. | 1   a    1    a |
   2. | 2   b    2    b |
   3. | 3   c    3    c |
   4. | 4   d    4    d |
      +-----------------+
Although nb is a numeric variable, it looks like a string variable because the encode command added value labels to it.
. list nb, nolab
      +----+
      | nb |
      |----|
   1. |  1 |
   2. |  2 |
   3. |  3 |
   4. |  4 |
      +----+
二维码

扫码加我 拉你入群

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

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

2017-7-31 21:08:26
Libaoxinxin 发表于 2017-7-31 19:43
The most common cause of this error message is that you are trying to use a string variable with a c ...
用了你说的方法,但是得到了蓝色字体的代码
二维码

扫码加我 拉你入群

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

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

2017-7-31 21:08:28
Libaoxinxin 发表于 2017-7-31 19:43
The most common cause of this error message is that you are trying to use a string variable with a c ...
用了你说的方法,但是得到了蓝色字体的代码
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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