|
Macros for SAS Application Developers
https://github.com/sasjs/core |
Guess the primary key of a table. More...
Go to the source code of this file.
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 composite keys of 2 to 6 columns
The library of the target should be assigned before using this macro.
Usage:
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas"; %inc mc; %mp_guesspk(sashelp.class,outds=classpks)
| [in] | baseds | The dataset to analyse |
| [out] | outds= | (mp_guesspk) Output dataset to contain the possible PKs |
| [in] | max_guesses= | (3) The total number of possible primary keys to generate. A table may have multiple (unlikely) PKs, so no need to list them all. |
| [in] | min_rows= | (5) The minimum number of rows a table should have in order to try and guess the PK. |
| [in] | ignore_cols | (0) Space seperated list of columns which you are sure are not part of the primary key (helps to avoid false positives) |
| [in] | mdebug= | Set to 1 to enable DEBUG messages and preserve outputs |
Definition in file mp_guesspk.sas.