【发布时间】:2019-12-17 06:53:13
【问题描述】:
考虑以下变量:
clear
input str18 string
"abc bcd cde"
"def efg fgh"
"ghi hij ijk"
end
我可以使用regexm() 函数提取所有出现的abc、cde 和def:
generate new = regexm(string, "abc|cde|def")
list
|string new |
|--------------------|
| abc bcd cde 1 |
| def efg fgh 1 |
| ghi hij ijk 0 |
我怎样才能得到以下内容?
|string wanted |
|--------------------------|
| abc bcd cde abc cde |
| def efg fgh def |
| ghi hij ijk |
这个问题是这里回答的问题的延伸:
【问题讨论】:
-
术语 column 在 Stata 中仅适用于矩阵或表格的列。
标签: regex stata string-matching