分享由爬虫俱乐部 (Haitao SI, Yuan XUE, and Muhammad Usman 等人) 所推出之 addbefore --- 在变量前添加数字或字符。
- // ssc install addbefore
- * Example generated by -dataex-. To install: ssc install dataex
- clear
- input str15 v1 float(v2 v3) str15 v4
- "a" 1 22 "a"
- "dd2" 56555 666 "dd2"
- "2" 22 55 "2"
- "65" 66 228 "65"
- "889"22 33 "889"
- "525"55 889 "525"
- end
- * Add a value before v1 v2 v3 v4 , digit is 7. By default, the character is 0.
- addbefore v1 v2 v3 v4, digits(7) gen(v5 v6 v7 v8)
- * Add a value before v2 v3 , digit is 7, and specify the character as 1.
- addbefore v2 v3, d(7) c(1) replace
- * Add a value before v1 v4 , digit is 7, and specify the character as a.
- addbefore v1 v4, d(7) c(a) replace
复制代码