Hi,
At the moment, I have an algorithm that tries to link a contract to another -> group A links to group B.
I need to store relations CTR(A) matches with CTR(B).
Software starts trying to match by client fiscal code and proceeds selecting the best link possible (using a score).
Next iterations do the same with unlinked contracts still available: now it is not using the client fiscal code but the one of people listed as 'friend' within the contract. Until now I considered checking only friends in scope of contracts being part of group A, CTR(A).
Every CTR has its unique 'friends'.
So, for every contract there will be max 6 people in total considered by this logic.
They ask me to keep trying, if contracts aren't linked yet, matching with 'friends' of contracts in set B, CTR(B).
Here comes my question. I thought of creating a dataset matrix containing all possible links within sets.
When I choose a link though, I need to remove every other occurrence of chosen CTR it in my matrix. If I link contract A1 to contract B1 I need to delete every row containing one or the other. Just to be clear, when I decide a link in my code I need to remove every 'what if' scenario not any more plausible.
Is it possible to do something like that within just one data step?
Do you have any similar experience?
I want to avoid cycling too much if possible.
Instead of creating a matrix and select the best fit, why not let SAS take care of that? That is exactly what SQL does when it joins (creates all possible combinations of rows that fit the ON clause):
proc sql;
select a.ctr, /* other columns */
case
/* case statements to calculate score */
end as score
from a join b on a.ctr=b.ctr
group by a.ctr
having calculated score=max(calculated score)
;
If you need further help, you will have to supply some example data (preferably as data step code).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.