Here is another example which will work in all scenarios.
data inds;
invar = "There was once a merchant who employed many carpenters and masons to build a temple in his garden. Regularly, they would start work in the morning; The Monkey And The Wedge - Panchatantra Story Pictureand take a break for the mid-day meals, and return to resume work till evening. One day, a group of monkey arrived at the site of the building and watched the workers leaving for their mid-day meals. One of the carpenters was sawing a huge log of wood. Since, it was only half-done; he placed a wedge in between to prevent the log from closing up. He then went off along with the other workers for his meal.";
output;
invar = "Small string";
output;
invar = " ";
output;
run;
data outds_row;
set inds;
obs_seq = _n_;
length outvar $200;
sub_invar = invar;
itrno = 0;
do until (sub_invar = " ");
dlmpos = 199 - lengthn(scan(reverse(substrn(sub_invar, 1, 200)), 1, " "));
outvar = strip(substrn(sub_invar, 1, dlmpos));
sub_invar = strip(substrn(sub_invar, dlmpos + 1));
itrno + 1;
output;
end;
drop sub_invar dlmpos;
run;
proc sort data = outds_row;
by obs_seq itrno;
run;
proc transpose data = outds_row out = outds_col prefix = outvar;
by obs_seq;
id itrno;
var outvar;
run;