【问题标题】:How do I find and replace a part of a string variable in Stata?如何在 Stata 中查找和替换字符串变量的一部分?
【发布时间】:2014-02-14 08:33:07
【问题描述】:

我正在使用一个基本上是 URL 的变量。所以观察值包括例如值

  • www.google.com
  • https://www.google.com
  • https://yahoo.movies.com

我正在尝试创建一个 do 文件以将这些文件中的一堆导入 Stata,并且需要一种可靠的方法来从各种 URL 中的这些变量中删除 www.https:// 部分。

在 Excel 中,我只需找到 https://www. 并将其替换为空即可,如何在 Stata 中实现相同的效果?

我在 Windows 8 Pro 64 位上使用 Stata 13.1 SE。

【问题讨论】:

    标签: stata


    【解决方案1】:

    您可以使用subinstr() 函数。

    例子:

    subinstr("this is this","is","X",.) = "thX X thX"
    

    【讨论】:

    • 谢谢,这正是我想要的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-15
    • 2020-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    相关资源
    最近更新 更多