我目前正在清理带有邮政编码的数据集,以便将它们地理编码为ArcMAP。
目前,已清除邮政编码以删除所有空格(前导,尾随等)。我想要的是在最后三个字符之前插入一个空格,我不确定如何做到这一点。它是一个字符串变量。
gen str8=postcodenew=subinstr(postcode," ", "", .)
我这样做是为了删除空格,但现在想要输入最后一个字符中的三个字符。
答案 0 :(得分:1)
给出的代码
gen str8=postcodenew=subinstr(postcode," ", "", .)
是非法的,但可能是
的拼写错误gen str8 postcodenew = subinstr(postcode," ", "", .)
想要的可能是
gen postcodenew2 = substr(postcodenew, 1, length(postcodenew) - 3) + " " + substr(postcodenew, -3, 3)