文章2021_01_05_stata15在mac上的dta编码问题和系统crash

stata15

macos 10.15.3

问题:无法unicode中文的dta数据,unicode invalid option时,出现系统crash

解决: 值标签损坏导致的crash, 区分标签和内容分别转码。

https://www.statalist.org/forums/forum/general-stata-discussion/general/1488060-stata-15-crashes-when-using-unicode-translate

We have two users reporting the similar issue. Both are caused by the original dataset contains corrupted value label(s). The dataset works fine when the particular value label(s) are not used. But when -unicode translate- or other Stata commands try to use the corrupted value label(s), it will potentially crash Stata. 

To work around it, you may do the following, 
 

Code:

// I use test.dta as an example

// first we would like to save all value labels in test.dta to a do-file mylab.do
use "test.dta", clear
label save  _all using  mylab, replace

// then we drop all value labels from the dataset, and save the new dataset as test2.dta
label drop _all
save test2.dta, replace

// now we can translate test2.dta
clear
unicode encoding set gb18030
unicode translate "test2.dta", invalid(mark) transutf8

// now we translate the mylab.do
clear
unicode encoding set gb18030
unicode translate mylab.do, invalid(ignore)

// now we can re-attach value labels
use "test2.dta", clear
do mylab.do

Now test2.dta contains translated dataset with fixed value labels, Please email Stata tech support at tech-support@stata.com with the dataset attached if the problem persists.

 

# 据称,stata14后的数据采用了unicode编码,所以除了上面的crash问题,还有低版本和高版本数据的转化问题,如stata5-12和stata13,stata14及以上之间的转化问题。

首先,分析一下文件编码是必要的,如果确定原始文件的编码是gb18030,可以set。

gb18030,gb2312,GBK。

cd ...

unicode analyze test.dta

unicode encodinng set gb18030

unicode translate test.dta

https://www.bilibili.com/video/BV1pa4y1j7eF/?spm_id_from=trigger_reload

 

未解决的问题:stata中的科学计数数值转到r中时,会变成字符。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python和Stata都是数据分析领域常用的工具,它们各有优缺点,具体使用哪个要根据具体需求而定。下面是两者的比较: 1. 功能方面 Python是一门通用编程语言,可以用来进行数据分析、机器学习、Web开发等多种应用。Python有大量的数据分析库,如NumPy、Pandas、Scipy和Matplotlib等,还有一些强大的机器学习框架,如TensorFlow、Keras和PyTorch等。 Stata则是专业的统计分析软件,主要用于数据清洗、可视化和统计分析。Stata有丰富的数据操作和统计分析功能,特别擅长于面板数据分析和处理,也有一些可视化工具和机器学习功能。 2. 学习成本 Python作为一门通用编程语言,学习曲线相对较长,需要掌握基本的编程概念和语法,但是Python的社区非常活跃,有很多在线教程和课程,学习资源非常丰富。 Stata相对来说学习成本较低,因为它的语法比较简单明了,上手较快。同时Stata也有自己的官方文档和社区支持,可以帮助用户快速上手。 3. 数据处理速度 Python的数据处理速度相对较慢,特别是在处理大规模数据时,需要使用一些优化技巧,如向量化和并行计算等。 Stata在数据处理速度方面比较快,尤其是在数据清洗和面板数据分析方面表现出色。 综上所述,Python适合进行复杂的数据分析和机器学习任务,而Stata则适合进行简单的数据清洗和统计分析任务。但是,在实际应用中,两者也可以结合使用,根据具体需求选择不同的工具。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值