Hello,
I have a string variable that is a list of words.
I would like to count how many time each possible pairwise combination of two words occurs in the whole database and then generate a variable that sums the counts for all the pairwise combinations in the observation.
So for example, for the first observation I want to generate a variable that is the sum of the total occurrence of "d" and "c", which is 3, plus the total occurrence of "d" and "a", which is 3, plus the total occurrence of "c" and "a", which is 2.
Thank you for any hint you can provide!
I have a string variable that is a list of words.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input strL items "d;c;a;" "a;b;c;d;" "d;a;f;e;h;" "n;e;o;c;d" end
I would like to count how many time each possible pairwise combination of two words occurs in the whole database and then generate a variable that sums the counts for all the pairwise combinations in the observation.
So for example, for the first observation I want to generate a variable that is the sum of the total occurrence of "d" and "c", which is 3, plus the total occurrence of "d" and "a", which is 3, plus the total occurrence of "c" and "a", which is 2.
Thank you for any hint you can provide!
Comment