Hi Experts,
I am trying to get all combinations of words in preceding order available in a given string e.g.
Suppose I have a string like "The cow jumps over the moon"
and want combinations like..
The cow
The jumps
The over
The the
The Moon
cow jumps
cow over
cow the
cow moon
jumps over
jumps the
jumps moon
over the
over moon
the moon
please help me to achieve the same..
I m trying the following code:
data test; sen = "The cow jumps over the moon"; run;
data test1; set test; length sen1 $100.; sen1=""; retain sen1; do i=0 to count(compbl(TRIM(sen))," "); do j=1 to 2; sen1=compbl(sen1||" "||compbl(trim(scan(compbl(TRIM(sen)),i+j," ","MO")))); ngram= j; r=count(TRIM(sen)," "); x=count(compbl(TRIM(sen))," "); output; end; sen1=""; end; if ngram=2; run;
Thnx
Rahul
... View more