Hi
I have below dataset
data have;
input id val1 $ val2 $;
datalines;
1 123 CDE
1 345 CEF
1 756 CEF
1 458 HHH
1 789 JJJ
1 999 KLM
1 777 KLM
;
depending on val2 I need to concatenated val1 and get unique combination, output should be like something as shown below. I have multiple ids, for simplicity sake, I am just showing one id.
Edit1: In this table val2 column have duplicates for CEF and KLM values, rule is the concatenation of val1 should have only single combination of CEF and KLM. Below is little elaborate discussion on this
first row shown in want dataset has 123,345(CEF),458,789,999(KLM) is having only one row with respect val2 column of CEF and
KLM (first instances of CEF and KLM).
second row has 123,756(second instance of CEF),458,789,999( first instance of KLM)
third row has 123,345 (first instance of CEF),458,789,777(second instance of KLM)
fourth row has 123,756 (second instance of CEF),,458,789,777 (second instance of KLM)
data want;
Input Val $50.;
datalines;
123,345,458,789,999
123,756,458,789,999
123,345,458,789,777
123,756,458,789,777
;
I have tried first. and last. but I am unable to make unique combinations. Please let me know if you have any suggestions or ideas for this problem an also let me know if something is unclear.
... View more