hello, I have a question, how to sArray plit a into two as required:
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str200 var1 "马雄飞;廉新颖;贾永锋;韩旭;夏甫;姜永海;郇环;MA;Xiongfei;LIAN;Xinying;JIA;Yongfeng;HAN;Xu;XIA;Fu;JIANG;Yonghai;HUAN;Huan" "李春晖;田雨桐;赵彦伟;王烜;LI;Chun-hui;TIAN;Yu-tong;ZHAO;Yan-wei;WANG;Xuan" "杜兆林;张志浩;曹慧哲;郑彤;王鹏;DU;Zhaolin;ZHANG;Zhihao;CAO;Huizhe;ZHENG;Tong;WANG;Peng" "练继建;孙萧仲;马超;许红师;孙秋慧;Lian;Jijian;Sun;Xiaozhong;Ma;Chao;Xu;Hongshi;Sun;Qiuhui" "郭维维;龙岩;GUO;Wei-wei;LONG;Yan" "许亚南;韩周洋;Xu;Ya'nan;Han;Zhouyang" "顾瑛杰;夏豪刚;GU;Ying-jie;XIA;Hao-gang" "闫凡龙;Yan;Fanlong" "王家彪;雷晓辉;王浩;廖卫红;李宏亮;刘松;WANG;Jiabiao;LEI;Xiaohui;WANG;Hao;LIAO;Weihong;LI;Hongliang;LIU;Song" "杨星;崔巍;穆祥鹏;国洁;YANG;Xing;CUI;Wei;MU;Xiangpeng;GUO;Jie" "武佳倩;汤铃;李玲;余乐安;WU;Jia-qian;TANG;Ling;LI;Ling;YU;Le-an" "卢滨;陈义中;常文婷;LU;Bin;CHEN;Yizhong;CHANG;Wenting" "张永领;杨小二;ZHANG;Yongling;YANG;Xiaoer" "庞治邦;刘波;周振;PANG;Zhi-bang;LIU;Bo;ZHOU;Zhen" "王芳;Wang;Fang" end
Can recognize the first letter or replace the first letter, and then use the code:
egen var2 = ends(var1),punct("the first letter") head
and the divide the vars into tow
I hope the final results are as shown in the figure:
thank you for your help. thank you very much.
0 Response to how to split a var(string) into two vars
Post a Comment