Hello, The basic goal of the program is to split any values that has range of values separated by dash or delimiter to be split into rows. The file we get is in excel format and we do not know which rows will need the split, the program should be able to detect it. So, my program does check the individual columns, I also know how to do the splitting for just one variable, but I am not sure of how to perform multiple splits on the same data. So, only the first column to be split works correctly, but the next column does not get split correctly. The data looks like this: var1 var2 var3 999997-999999 1 999997-999999 7,8,9 999997-999999 2 999997-999999 7,8,9 1 999997-999999 1 1 This is what the expected data set should look like: var1 var2 var3 999997 1 999998 1 999999 1 999997 7 999998 7 999999 7 999997 8 999998 8 999999 8 999997 9 999998 9 999999 9 999997 2 999998 2 999999 2 999997 7 999998 7 999999 7 999997 8 999998 8 999999 8 999997 9 999998 9 999999 9 999997 1 1 999998 1 1 999999 1 1 Here is the code I am using: data test;
set adult;
array vars {*} _character_;
do i = 1 to dim(vars);
if findc(vars[i],'-') > 0 then do;
first=scan(vars[i],1,'-');
last=scan(vars[i],2,'-');
pos = indexc(vars[i], '-');
do range = first to last;
len = length(compress(put(range,32.)));
len_new = pos - 1 - len;
if len_new ne 0 then vars[i] = cats(repeat('0', len_new-1), range);
else vars[i] = range;
output;
end;
end;
if findc(vars[i],',') > 0 then do;
do j=1 by 1 while(scan(vars[i],j,',') ^=' ');
new=scan(vars[i],j,',');
output;
end;
end;
end;
*drop i j;
run; Please, help me fix this. Thanks!
... View more