I have a Data Set containing some observations (say 10).
I have to merge two observation if they are similar.
Now limitations are:
We can merge only consecutive observation and
In one step only one merge should happen on one dataset (i.e if obs# 1 and 2 are similar, and obs# 4 and 5 are similar, we can't merge them in single step), so basically as soon as one merging is done I should get out of the merging step, and again run the merging procedure on the new data set obtained by first merging.
The technique i tried to follow is: I look for rows which are more similar. Say 1 and 2 are more similar (have less "p-value") than 4 and 5. Then I merge 1 and 2 first, otherwise I merge 4 and 5 first. Problem is that some times "p-values" are similar for more than 1 pair of observations. Then I have to merge any 2 observations (1 pair) and again run the merging procedure on new dataset.
Dataset Contains following fields:
GoodCount, TotalCount, pValue
Here is the Code which I tried: (If you have a solution for my problem you can ignore the code and just tell me the solution, otherwise please tell me where i m wrong)
/* some code here to regenerate p values every time we call this macro, works fine*/
I'm not sure I understand your challenge - can you perhaps provide some 'before' and 'after' sample data.
Is it something like this your are trying ?[pre]
input value1 value2;
retain key 0;
prev_val = lag1(value1);
if _n_ = 1 then key = 1;
else if prev_val*0.9 <= value1 <= prev_val*1.1 then;
[/pre]In this sample code each record gets a (new) surrogate key based on if the value (current record) is within a range (based on the previous record). After this you can use the new key, to merge, summarize etc. your data.