楼主: 马飞112233
37866 9

[数据管理求助] stata空白值删除 [推广有奖]

  • 0关注
  • 0粉丝

大专生

91%

还不是VIP/贵宾

-

威望
0
论坛币
811 个
通用积分
42.1209
学术水平
1 点
热心指数
2 点
信用等级
1 点
经验
619 点
帖子
12
精华
0
在线时间
101 小时
注册时间
2012-4-30
最后登录
2019-3-31

楼主
马飞112233 发表于 2018-5-26 14:24:16 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
有一字符型变量下有空白格,怎么删除。没有原始的excel或者csv文件
二维码

扫码加我 拉你入群

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

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

关键词:字符型 stata数据处理

沙发
黃河泉 在职认证  发表于 2018-5-26 15:48:23
你若要问程序,永远附上资料;若要附上资料,永远用 dataex 印出资料;先 ssc install dataex (并见说明),将原始 Stata 资料中具有”代表性”的一部分资料列出,以供有意回答者实验之用,并能提供具体操作指令。并请参考 http://www.jianshu.com/p/9870080fe769,  https://bbs.pinggu.org/thread-5048204-1-1.html, 与 https://bbs.pinggu.org/thread-5917273-1-1.html
已有 1 人评分经验 论坛币 收起 理由
葫芦娃大王 + 10 + 10 精彩帖子

总评分: 经验 + 10  论坛币 + 10   查看全部评分

藤椅
大壹子 发表于 2018-5-26 21:38:30 来自手机
你是字符型的吧?先占转为数值型的变量吧?

板凳
steventung 发表于 2018-5-28 12:56:29
替换字符串中的字符
在本例中,可以用如下命令
subinstr(varname," ","",.)

以下是命令参考
1.subinstr(s1,s2,s3,n)
Description:s1, where the first n occurrences in s1 of s2 have been replaced with s3
subinstr() is intended for use with only plain ASCII characters and for use by programmers who want to perform byte-based substitution.  Note that any Unicode character beyond ASCII range (code point greater than 127) takes more than 1 byte in the UTF-8 encoding; for example, é takes 2 bytes.
To perform character-based replacement in Unicode strings, see usubinstr().
If n is missing, all occurrences are replaced.
Also see regexm(), regexr(), and regexs().
subinstr("this is the day","is","X",1) = "thX is the day"
subinstr("this is the hour","is","X",2) = "thX X the hour"
subinstr("this is this","is","X",.) = "thX X thX"
Domain s1:strings (to be substituted into)
Domain s2:strings (to be substituted from)
Domain s3:strings (to be substituted with)
Domain n: integers > 0 or missing
Range:strings

2.subinword(s1,s2,s3,n)
Description:  s1, where the first n occurrences in s1 of s2 as a word have been replaced with s3
A word is defined as a space-separated token.  A token at the beginning or end of s1 is considered space-separated.  This is different from Unicode word, which is a language unit based on either a set of word-boundary rules or dictionaries for several languages (Chinese, Japanese, and Thai).  If n is missing, all occurrences are replaced.
Also see regexm(), regexr(), and regexs().
subinword("this is the day","is","X",1) = "this X the day"
subinword("this is the hour","is","X",.) = "this X the hour"
subinword("this is this","th","X",.) = "this is this"
Domain s1:strings (to be substituted for)
Domain s2:strings (to be substituted from)
Domain s3:strings (to be substituted with)
Domain n: integers > 0 or missing
Range:strings
Remarks
Use function usubinstr() if your string contains Unicode characters.

报纸
马飞112233 发表于 2018-5-31 20:56:42
steventung 发表于 2018-5-28 12:56
替换字符串中的字符
在本例中,可以用如下命令
subinstr(varname," ","",.)
已找到命令
misstable summarize // 所有变量
misstable sum var // 指定变量
drop if missing(var1,var2,var3,var4) //如果四个变量中有一个有缺漏值,即那条观察值就被删除
已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
yybys + 1 + 1 + 1 + 1 精彩帖子

总评分: 论坛币 + 1  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

地板
yw1126 在职认证  发表于 2019-5-7 01:35:13
replace v=subinstr(v," ","",.)

7
520wujing 发表于 2021-7-9 15:17:06
马飞112233 发表于 2018-5-31 20:56
已找到命令
misstable summarize // 所有变量
misstable sum var // 指定变量
感谢楼主的回复,比很多文不对题的回复强多了

8
xinyujay 发表于 2022-7-25 22:20:16
520wujing 发表于 2021-7-9 15:17
感谢楼主的回复,比很多文不对题的回复强多了
很好用的命令,对回复深有同感,看似长篇大论,实在文不对题,臭不可闻。既不好好看问题,也不认真回复,浪费别人时间。

9
xyq315 学生认证  发表于 2023-12-16 23:12:10
drop if X == "" 这个能删字符型空值

10
世上无难事1 发表于 2024-1-5 12:19:01
xyq315 发表于 2023-12-16 23:12
drop if X == "" 这个能删字符型空值
试了一下字符型(string)数据,drop if X == "" 这个有用,misstable sum var,这个没用。其他格式的数据不清楚。

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-18 18:44