全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
37711 9
2018-05-26
有一字符型变量下有空白格,怎么删除。没有原始的excel或者csv文件
二维码

扫码加我 拉你入群

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

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

全部回复
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
二维码

扫码加我 拉你入群

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

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

2018-5-26 21:38:30
你是字符型的吧?先占转为数值型的变量吧?
二维码

扫码加我 拉你入群

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

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

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.
二维码

扫码加我 拉你入群

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

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

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) //如果四个变量中有一个有缺漏值,即那条观察值就被删除
二维码

扫码加我 拉你入群

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

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

2019-5-7 01:35:13
replace v=subinstr(v," ","",.)
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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