我正在尝试从以下字符串变量中删除引号:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str46 mags
`"Automotive" News"""'
"Automobile"
`""Aviation Week and Space Technology""'
`"Technical Analysis "of Stocks "& Commodities"""'
`""Bloomberg""" Businessweek""'
end
但是,我得到一个错误:
replace mags = subinstr(mags, """, "", .)
too few quotes
r(132);
我的代码有什么问题?
答案 0 :(得分:1)
您需要在subinstr()
函数中使用 compound 双引号:
generate wanted = subinstr(mags, `"""', "", .)
list wanted
+--------------------------------------------+
| wanted |
|--------------------------------------------|
1. | Automotive News |
2. | Automobile |
3. | Aviation Week and Space Technology |
4. | Technical Analysis of Stocks & Commodities |
5. | Bloomberg Businessweek |
+--------------------------------------------+