Production Ready Macros for SAS Application Developers File Reference

Guess the primary key of a table. More...

Go to the source code of this file.

Detailed Description

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 "";
%inc mc;
basedsThe 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.


Allan Bowe

Definition in file