Reputation: 788
I have the following dataset
ID REGION NUMTYPE
NY us;ne 1015; 10x16
BO us;ne 1015; 10x17
ID nonus 1018
I would like to add another column "REGION_NUMTYPE" which has all the combinations of region and num type per row separated by the ";"
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
Is there a simple way to do this ? Many Thanks for your help
Upvotes: 1
Views: 76
Reputation: 12465
Easiest way would be a double loop.
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;
Upvotes: 4