【发布时间】:2019-08-09 12:18:31
【问题描述】:
我正在使用 Stata 15,我想根据另一个字符串变量的内容创建一个新的字符串变量。
考虑以下玩具变量:
clear
input str18 string
"a b c"
"d e f"
"g h i"
end
我知道我可以使用regexm() 函数提取所有出现的a、b、d 和g:
generate new = regexm(string, "a|c|d|g")
list
|string new |
|--------------|
| a b c 1 |
| d e f 1 |
| g h i 1 |
但是,我怎样才能获得以下信息?
|string new |
|----------------|
| a b c a c |
| d e f d |
| g h i g |
【问题讨论】: