楼主: xtydkb
26305 21

[编程问题求助] wind数据转为国泰安数据 stata命令 [推广有奖]

11
arlionn 在职认证  发表于 2018-12-17 16:41:43 |只看作者 |坛友微信交流群
我前两天也刚好处理 Wind 数据,下面是自动抽取第二行文字信息作为变量标签的程序。尚未来得及封装发布。

  1. *-------
  2. *-调入 Wind 数据的小程序

  3. cap program drop usewind
  4. program define usewind
  5.    args excel dtaname
  6.    
  7.    *-取出变量中文标签
  8.    import excel using "`excel'", clear first
  9.    
  10.    qui ds, varwidth(30)
  11.    global vlist "`r(varlist)'"
  12.    *dis "$vlist"
  13.    
  14.    *-正式导入数据,英文变量名,增加中文标签
  15.    import excel using "`excel'", clear first
  16.    *-变量英文名          
  17.    global n = wordcount("$vlist")          //变量个数
  18.    global aa ""  //存放英文变量名
  19.    forvalues i=1/$n{
  20.      global aa "$aa a`i'"
  21.    }
  22.    *dis "$vlist"
  23.    *dis "$aa"
  24.    rename ($vlist) ($aa)
  25.    
  26.    tokenize $vlist  // `1' `2' 分别存放 1st, 2rd 中文变量名, ……
  27.    forvalues i=1/$n{
  28.      label var a`i' "``i''"
  29.    }

  30.    save "`dtaname'", replace
  31.    
  32. end
复制代码


使用道具

12
郑世杰0522 发表于 2019-4-19 15:41:51 |只看作者 |坛友微信交流群
请问 连玉君老师,如果是日度数据这个也行嘛 谢谢

使用道具

13
六月周周 发表于 2019-5-11 20:27:34 |只看作者 |坛友微信交流群
黃河泉 发表于 2018-12-17 11:34
我用 Stata 15,
黄老师好,请问这里的j是什么意思呢?

使用道具

14
六月周周 发表于 2019-5-11 20:28:53 |只看作者 |坛友微信交流群
黃河泉 发表于 2018-12-17 11:34
我用 Stata 15,
我用STATA14没有做出来结果,不太明白J的作用是什么,请老师指教

使用道具

15
黃河泉 在职认证  发表于 2019-5-12 07:30:29 |只看作者 |坛友微信交流群
六月周周 发表于 2019-5-11 20:28
我用STATA14没有做出来结果,不太明白J的作用是什么,请老师指教
请 help reshape。

使用道具

16
bisou4615 发表于 2020-2-4 11:09:42 |只看作者 |坛友微信交流群
variable id does not uniquely identify t
> he observations
    Your data are currently wide.  You
    are performing a reshape long.
    You specified i(code) and j(year).
    In the current wide form, variable
    code should uniquely identify the
    observations.  Remember this
    picture:

         long                           
>      wide
        +---------------+               
>     +------------------+
        | i   j   a   b |               
>     | i   a1 a2  b1 b2 |
        |---------------| <--- reshape -
> --> |------------------|
        | 1   1   1   2 |               
>     | 1   1   3   2  4 |
        | 1   2   3   4 |                   | 2   5   7   6  8 |
        | 2   1   5   6 |                   +------------------+
        | 2   2   7   8 |
        +---------------+
    Type reshape error for a list of the problem observations.
r(9);

.
这是什么意思呢

使用道具

17
白青浅 发表于 2020-7-10 17:38:05 |只看作者 |坛友微信交流群
黃河泉 发表于 2018-12-17 11:34
我用 Stata 15,
大赞

使用道具

18
andreawzy 学生认证  发表于 2020-9-14 10:24:50 |只看作者 |坛友微信交流群
麒零_之恋 发表于 2018-12-17 12:03
我有个问题,我也是一直费解。有时候,我reshape完数据,会发现新的数据和原来的数据不一样了,比如7.23变 ...
有可能只是excel设置的数据格式问题

使用道具

19
shana0225 学生认证  发表于 2021-9-11 19:56:34 |只看作者 |坛友微信交流群
黃河泉 发表于 2018-12-17 11:34
我用 Stata 15,
不好意思,我刚刚点错了,踩了一下,对不起哈。

使用道具

20
Toby_sy 发表于 2022-6-17 10:38:57 |只看作者 |坛友微信交流群
小白刚开始用 想找附件下载不小心点踩了一个啊啊啊 实在是抱歉 麻烦问一下附件的数据在哪里找呢?

使用道具

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

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

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

GMT+8, 2024-5-8 02:55