楼主: xingyun1688
4988 5

[数据管理求助] stata 怎么处理月份为英文缩写的时期型变量 [推广有奖]

  • 9关注
  • 20粉丝

已卖:1981份资源

副教授

23%

还不是VIP/贵宾

-

威望
0
论坛币
4967 个
通用积分
158.3433
学术水平
33 点
热心指数
29 点
信用等级
24 点
经验
2591 点
帖子
324
精华
0
在线时间
943 小时
注册时间
2011-4-4
最后登录
2026-1-16

楼主
xingyun1688 学生认证  发表于 2017-3-24 20:51:44 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
stata 怎么处理月份为英文缩写的时期型变量
例如我的日期为“31oct16”。日月年
直接用 date(var, "DMY") 不行
二维码

扫码加我 拉你入群

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

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

关键词:Stata 怎么处理 英文缩写 tata date 英文缩写

回帖推荐

夏目贵志 发表于3楼  查看完整内容

用gen date=date(datestr,"DM20Y")即可 help datetime_translation

沙发
xingyun1688 学生认证  发表于 2017-3-24 22:41:59
本人已经解决,使用了笨办法,供大家参考批评!
deadline 即为所处理的时间变量

******时期变量处理

replace deadline = lower(deadline)

split deadline, parse("-") gen(ndate) notrim

rename ndate1 date
rename ndate2 month
rename ndate3 year
*****月份为英文缩写处理方法*******************

replace month = subinstr(month, "jan", "01",.)
replace month = subinstr(month, "feb", "02",.)
replace month = subinstr(month, "mar", "03",.)
replace month = subinstr(month, "apr", "04",.)
replace month = subinstr(month, "may", "05",.)
replace month = subinstr(month, "jun", "06",.)
replace month = subinstr(month, "jul", "07",.)
replace month = subinstr(month, "aug", "08",.)
replace month = subinstr(month, "sep", "09",.)
replace month = subinstr(month, "oct", "10",.)
replace month = subinstr(month, "nov", "11",.)
replace month = subinstr(month, "dec", "12",.)

**********************************************
*****将year格式补充完整

replace year = "20" + year


destring date month year, replace

gen deadlineymd = mdy(month, date, year)
gen deadlineym = ym(year, month)
format deadlineym %tm

deadline.PNG (8.14 KB)

deadline.PNG

藤椅
夏目贵志 发表于 2017-3-25 05:01:28
用gen date=date(datestr,"DM20Y")即可
help datetime_translation

板凳
xingyun1688 学生认证  发表于 2017-3-25 08:38:51
夏目贵志 发表于 2017-3-25 05:01
用gen date=date(datestr,"DM20Y")即可
help datetime_translation
谢谢 我试一下

报纸
F.Wang 发表于 2023-11-30 21:18:17
救我大命了,谢谢楼主

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-2-7 15:34