Guess the primary key of a table. More...
Tries to guess the primary key of a table based on the following logic:
Columns with nulls are ignored Return only column combinations that provide unique results Start from one column, then move out to include composite keys of 2 to 6 columns
The library of the target should be assigned before using this macro.
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas"; %inc mc; %mp_guesspk(sashelp.class,outds=classpks)
|baseds||The dataset to analyse|
|outds=||The output dataset to contain the possible PKs|
|max_guesses=||The total number of possible primary keys to generate. A table is likely to have multiple unlikely PKs, so no need to list them all. Default=3.|
|min_rows=||The minimum number of rows a table should have in order to try and guess the PK. Default=5.|
Definition in file mp_guesspk.sas.