【问题标题】:How do I lowercase the contents of ALL string variables?如何小写所有字符串变量的内容?
【发布时间】:2016-06-12 21:36:18
【问题描述】:

我正在尝试找出一种有效的方法来小写 Stata 中字符串变量的所有内容。我知道如何一次处理一个变量(使用名为 VARIABLE 的变量的示例),例如

replace VARIABLE = lower(VARIABLE)

有没有简单的办法,比如用下面的把所有变量名都小写:

rename *, lower

【问题讨论】:

    标签: string stata lowercase


    【解决方案1】:

    ds 将为您提供所有字符串变量的名称列表,之后您可以以通常的方式循环它们。另请参阅 findname (Stata Journal) 以获取用于查找满足特定条件的变量名称的替代命令。使用findname 的语法与findname, type(string) 类似。

    ds, has(type string) 
    foreach v in `r(varlist)' { 
        replace `v' = lower(`v') 
    } 
    

    【讨论】:

      猜你喜欢
      • 2018-04-13
      • 2011-05-25
      • 2018-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-13
      • 2017-12-19
      相关资源
      最近更新 更多