我有以下数据集
ID REGION NUMTYPE
NY us;ne 1015; 10x16
BO us;ne 1015; 10x17
ID nonus 1018
我想添加另一列" REGION_NUMTYPE"其中每行的区域和num类型的所有组合由&#34 ;;"
分隔ID REGION NUMTYPE REGION_NUMTYPE
NY us;ne 1015; 10x16 us1015; us10x16;ne1015;ne10x16
BO us;ne 1015; 10x17 us1015; us10x17;ne1015;ne10x17
ID nonus 1018 nonus1018
有一种简单的方法吗?非常感谢您的帮助
答案 0 :(得分:4)
最简单的方法是双循环。
data want;
set have;
format Region_NumType $2000.; /*Modify size if needed*/
do i=1 to countw(region,";");
do j=1 to countw(NumType,";");
Region_NumType = cats(Region_NumType,scan(region,i,";"),scan(NumType,j,";"),";");
end;
end;
run;