combining two columns separated by semicolons in SAS -
I have the following dataset
id field NUMTYPE NY us; 1015; 10x16 Bo Ours, 1015; 10x17 ID nonus 1018
I would like to add another column "REGION_NUMTYPE" which combines all fields and ";" ID field NUMTYPE REGION_NUMTYPE NY us; 1015; 10x16 US 1,015; Us10x16; Ne1015; Ne10x16bo us; 1015; 10x17 us1015; Us10x17; Ne1015; Ne10x17 id nonus 1018 nonus1018
An easy way to do this? Many thanks for your help
The easiest way would be to have a double loop.
want data; Is set; Format Area_Name Type 2000 $.; / * Change shape if necessary * / do I = 1 to countw (region, ";"); Do j = 1 to countw (NumType, ";"); Region_NumType = Cats (field_max type, scan (region, I, ";"), scan (Num type, J, ";", ",";);); End; End; Run;
Comments
Post a Comment