From efe4709dde5c7109aa8df8b0390268f719a8cfd9 Mon Sep 17 00:00:00 2001 From: Allan Bowe Date: Wed, 14 Oct 2020 16:42:04 +0200 Subject: [PATCH] chore: formatting in mp_guesspk --- all.sas | 30 +++++++++++++++--------------- base/mp_guesspk.sas | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/all.sas b/all.sas index 5c6619a..a4980aa 100644 --- a/all.sas +++ b/all.sas @@ -2921,9 +2921,9 @@ create table &outds (rename=( @brief Guess the primary key of a table @details 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 + * 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. @@ -2969,7 +2969,7 @@ create table &outds (rename=( /* get null count and row count */ %let tmpvar=%mf_getuniquename(); proc sql noprint; - create table _data_ as select + create table _data_ as select count(*) as &tmpvar %do i=1 %to &vcnt; %let var=%scan(&vars,&i); @@ -3003,10 +3003,10 @@ create table &outds (rename=( %put &sysmacroname: &baseds has no combination of unique records! Exiting.; %return; %end; - + /* now check cardinality */ proc sql noprint; - create table _data_ as select + create table _data_ as select %do i=1 %to &ppkcnt; %let var=%scan(&posspks,&i); count(distinct &var) as &var @@ -3130,7 +3130,7 @@ create table &outds (rename=( %end; %end; %end; - + %if &ppkcnt=4 %then %do; %put &sysmacroname: No more PK guess possible; %return; @@ -3146,7 +3146,7 @@ create table &outds (rename=( %let lev3=%scan(&posspks,&k); %if &lev1 ne &lev3 and &lev2 ne &lev3 %then %do l=4 %to &ppkcnt; %let lev4=%scan(&posspks,&l); - %if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then + %if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then %do m=5 %to &ppkcnt; %let lev5=%scan(&posspks,&m); %if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then %do; @@ -3168,7 +3168,7 @@ create table &outds (rename=( %end; %end; %end; - + %if &ppkcnt=5 %then %do; %put &sysmacroname: No more PK guess possible; %return; @@ -3184,17 +3184,17 @@ create table &outds (rename=( %let lev3=%scan(&posspks,&k); %if &lev1 ne &lev3 and &lev2 ne &lev3 %then %do l=4 %to &ppkcnt; %let lev4=%scan(&posspks,&l); - %if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then + %if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then %do m=5 %to &ppkcnt; %let lev5=%scan(&posspks,&m); - %if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then + %if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then %do n=6 %to &ppkcnt; %let lev6=%scan(&posspks,&n); - %if &lev1 ne &lev6 & &lev2 ne &lev6 & &lev3 ne &lev6 - & &lev4 ne &lev6 & &lev5 ne &lev6 %then + %if &lev1 ne &lev6 & &lev2 ne &lev6 & &lev3 ne &lev6 + & &lev4 ne &lev6 & &lev5 ne &lev6 %then %do; /* check for four level uniqueness */ - proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5 &lev6) + proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5 &lev6) out=&tmpds noduprec; by _all_; run; @@ -3213,7 +3213,7 @@ create table &outds (rename=( %end; %end; %end; - + %if &ppkcnt=6 %then %do; %put &sysmacroname: No more PK guess possible; %return; diff --git a/base/mp_guesspk.sas b/base/mp_guesspk.sas index cb83237..19a4161 100644 --- a/base/mp_guesspk.sas +++ b/base/mp_guesspk.sas @@ -3,9 +3,9 @@ @brief Guess the primary key of a table @details 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 + * 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. @@ -51,7 +51,7 @@ /* get null count and row count */ %let tmpvar=%mf_getuniquename(); proc sql noprint; - create table _data_ as select + create table _data_ as select count(*) as &tmpvar %do i=1 %to &vcnt; %let var=%scan(&vars,&i); @@ -85,10 +85,10 @@ %put &sysmacroname: &baseds has no combination of unique records! Exiting.; %return; %end; - + /* now check cardinality */ proc sql noprint; - create table _data_ as select + create table _data_ as select %do i=1 %to &ppkcnt; %let var=%scan(&posspks,&i); count(distinct &var) as &var @@ -212,7 +212,7 @@ %end; %end; %end; - + %if &ppkcnt=4 %then %do; %put &sysmacroname: No more PK guess possible; %return; @@ -228,7 +228,7 @@ %let lev3=%scan(&posspks,&k); %if &lev1 ne &lev3 and &lev2 ne &lev3 %then %do l=4 %to &ppkcnt; %let lev4=%scan(&posspks,&l); - %if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then + %if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then %do m=5 %to &ppkcnt; %let lev5=%scan(&posspks,&m); %if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then %do; @@ -250,7 +250,7 @@ %end; %end; %end; - + %if &ppkcnt=5 %then %do; %put &sysmacroname: No more PK guess possible; %return; @@ -266,17 +266,17 @@ %let lev3=%scan(&posspks,&k); %if &lev1 ne &lev3 and &lev2 ne &lev3 %then %do l=4 %to &ppkcnt; %let lev4=%scan(&posspks,&l); - %if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then + %if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then %do m=5 %to &ppkcnt; %let lev5=%scan(&posspks,&m); - %if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then + %if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then %do n=6 %to &ppkcnt; %let lev6=%scan(&posspks,&n); - %if &lev1 ne &lev6 & &lev2 ne &lev6 & &lev3 ne &lev6 - & &lev4 ne &lev6 & &lev5 ne &lev6 %then + %if &lev1 ne &lev6 & &lev2 ne &lev6 & &lev3 ne &lev6 + & &lev4 ne &lev6 & &lev5 ne &lev6 %then %do; /* check for four level uniqueness */ - proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5 &lev6) + proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5 &lev6) out=&tmpds noduprec; by _all_; run; @@ -295,7 +295,7 @@ %end; %end; %end; - + %if &ppkcnt=6 %then %do; %put &sysmacroname: No more PK guess possible; %return;