11-21-2017 12:50 PM
I am trying to create 2 letter bigram using arrays and then multiple steps (proc transpose and STDZ) to arrive the desired result.but i would like to achieve the same if there is way in minimizing all these steps and use just arrays.
I heard that this can be do able in e-miner/text mining module but is there a better a way to achieve through Base/Macros efficiently?
what I have tried is here
data test; input x$1-14 ; datalines; test one test two test three ; run; data bigram( drop=i); set test; n+1; do i=1 to lengthn(x)-1; v=substr(x,i,2);output; end; run;
Expecting this way to minimize number of intermediate steps and computationally efficient when deal with huge number of observations.
Taking two letter unique bi grams from three rows and occurrence of that bigram in a given string coded as 1 else 0
x te es st t o on ne tw wo th hr re ee test one 1 1 1 1 1 1 1 0 0 0 0 0 0 test two 1 1 1 1 0 0 0 1 1 0 0 0 0 test three 1 1 1 1 0 0 0 0 0 1 1 1 1
11-21-2017 01:19 PM
I don't think arrays will work here any more efficiently because you have the variable names as the ngrams. If they were part of the data then yes an array could work.
One other possible method:
There are (26 choose 2=325) possible combinations + all single values (26) = 351 combinations. Create all and then as you find each, change the indicator variable to a 1/0. But if your data is smaller it may be overkill here to have 351 variables.