Please try the below code
data have;
input text&$200.;
string=tranwrd(lowcase(text),'data','#');
cards;
Sports data is sufficient
Basketball Players Data is listed on the Olympic data
Soccer data and swimming data are not found in the Olympic data starting in the next month
;
proc sort data=have;
by string;
run;
data want(where=(count(string,'#')=i));
length new $100.;
set have;
by string;
do i = 1 to count(string,'#');
new=catx(' ', new, scan(scan(string,i,'#'),-1,' '));
output;
end;
run;
... View more