楼主: EvenDu
4919 10

[数据管理求助] 在stata中如何实现将一个变量下所有内容中的所有空格一次性变成下划线? [推广有奖]

  • 0关注
  • 0粉丝

小学生

28%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
46 点
帖子
4
精华
0
在线时间
4 小时
注册时间
2015-5-19
最后登录
2015-7-12

楼主
EvenDu 发表于 2015-5-19 23:08:38 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
比如indicator中包括production value,production volumn, production value added, 现在如何用一个公式将这些内容中空格的地方变成下划线,而不是用regexr语句一次次的加,是需要用到循环语句吗?具体如何写?
二维码

扫码加我 拉你入群

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

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

关键词:Stata 如何实现 tata 下划线 一次性 下划线 如何

沙发
andruw 在职认证  发表于 2015-5-19 23:26:18
strtoname() 函数

藤椅
普拉达魔鬼 发表于 2015-5-20 17:08:26
andruw 发表于 2015-5-19 23:26
strtoname() 函数
在stata里的help里没有找到这个命令啊?

板凳
andruw 在职认证  发表于 2015-5-20 18:15:44

Title

    [D] functions -- Functions


String function

    strtoname(s,p)
       Domain s:     strings
       Domain p:     0 or 1
       Range:        strings
       Description:  returns s translated into a Stata name.  Each character in s that is not allowed in a Stata name is converted to an underscore character, _.  If the first character
                         in s is a numeric character and p is not 0, then the result is prefixed with an underscore.  The result is truncated to 32 characters.

                         strtoname("name",1) = "name"
                         strtoname("a name",1) = "a_name"
                         strtoname("5",1) = "_5"
                         strtoname("5:30",1) = "_5_30"
                         strtoname("5",0) = "5"
                         strtoname("5:30",0) = "5_30"

    strtoname(s)
       Domain s:     strings
       Range:        strings
       Description:  returns s translated into a Stata name.  Each character in s that is not allowed in a Stata name is converted to an underscore character, _.  If the first character
                         in s is a numeric character, then the result is prefixed with an underscore.  The result is truncated to 32 characters.

                         strtoname("name") = "name"
                         strtoname("a name") = "a_name"
                         strtoname("5") = "_5"
                         strtoname("5:30") = "_5_30"
已有 1 人评分论坛币 学术水平 热心指数 收起 理由
SpencerMeng + 20 + 1 + 1 精彩帖子

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

报纸
heric221 在职认证  发表于 2015-5-20 20:41:45
andruw 发表于 2015-5-19 23:26
strtoname() 函数
嘿嘿……这个函数都被你找到了。

地板
andruw 在职认证  发表于 2015-5-20 21:04:36
heric221 发表于 2015-5-20 20:41
嘿嘿……这个函数都被你找到了。
stata就那么几个函数

7
普拉达魔鬼 发表于 2015-5-21 20:15:04
andruw 发表于 2015-5-20 18:15
Title

    [D] functions -- Functions
试过了还是不行,显示unrecognized command:  strtoname,是不是版本的问题,我的是stata10,没有这个公式么难道?

8
andruw 在职认证  发表于 2015-5-22 00:42:34
普拉达魔鬼 发表于 2015-5-21 20:15
试过了还是不行,显示unrecognized command:  strtoname,是不是版本的问题,我的是stata10,没有这个公式 ...
可能是版本问题。。。我用的13

9
andruw 在职认证  发表于 2015-5-22 00:50:26
普拉达魔鬼 发表于 2015-5-21 20:15
试过了还是不行,显示unrecognized command:  strtoname,是不是版本的问题,我的是stata10,没有这个公式 ...
试试有没有subinstr()函数,同样可以。。。

10
EvenDu 发表于 2015-5-25 16:22:32
感谢,这个有,国内同胞很靠谱热心!!!

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

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