1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-10 10:50:04 +00:00

chore: updating docs

This commit is contained in:
munja
2021-12-05 16:57:16 +00:00
parent 3295f3845e
commit fc14aaa37f
3 changed files with 21 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
# Macro Core # Macro Core
[![npm package][npm-image]][npm-url] [![npm package][npm-image]][npm-url]
[![Github Workflow][githubworkflow-image]][githubworkflow-url] [![Github Workflow][githubworkflow-image]][githubworkflow-url]
[![npm](https://img.shields.io/npm/dt/@sasjs/core)]() ![npm](https://img.shields.io/npm/dt/@sasjs/core)
![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@sasjs/core) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@sasjs/core)
[![License](https://img.shields.io/apm/l/atomic-design-ui.svg)](/LICENSE) [![License](https://img.shields.io/apm/l/atomic-design-ui.svg)](/LICENSE)
![GitHub top language](https://img.shields.io/github/languages/top/sasjs/core) ![GitHub top language](https://img.shields.io/github/languages/top/sasjs/core)

View File

@@ -37,6 +37,7 @@
<h4> Related Macros </h4> <h4> Related Macros </h4>
@li mp_getpk.test.sas @li mp_getpk.test.sas
@li mp_guesspk.sas
@version 9.3 @version 9.3
@author Macro People Ltd @author Macro People Ltd

View File

@@ -1,32 +1,37 @@
/** /**
@file mp_guesspk.sas @file
@brief Guess the primary key of a table @brief Guess the primary key of a table
@details Tries to guess the primary key of a table based on the following logic: @details Tries to guess the primary key of a table based on the following
logic:
* Columns with nulls are ignored * Columns with nulls are ignored
* Return only column combinations that provide unique results * Return only column combinations that provide unique results
* Start from one column, then move out to include composite keys of 2 to 6 columns * 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. The library of the target should be assigned before using this macro.
Usage: Usage:
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas"; filename mc url
"https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc; %inc mc;
%mp_guesspk(sashelp.class,outds=classpks) %mp_guesspk(sashelp.class,outds=classpks)
@param baseds The dataset to analyse @param baseds The dataset to analyse
@param outds= The output dataset to contain the possible PKs @param outds= The output dataset to contain the possible PKs
@param max_guesses= The total number of possible primary keys to generate. A @param max_guesses= (3) The total number of possible primary keys to generate.
table is likely to have multiple unlikely PKs, so no need to list them all. Default=3. A table may have multiple unlikely PKs, so no need to list them all.
@param min_rows= The minimum number of rows a table should have in order to try @param min_rows= (5) The minimum number of rows a table should have in order
and guess the PK. Default=5. to try and guess the PK.
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mf_getvarlist.sas @li mf_getvarlist.sas
@li mf_getuniquename.sas @li mf_getuniquename.sas
@li mf_nobs.sas @li mf_nobs.sas
<h4> Related Macros </h4>
@li mp_getpk.sas
@version 9.3 @version 9.3
@author Allan Bowe @author Allan Bowe
@@ -196,7 +201,8 @@
%let lev4=%scan(&posspks,&l); %let lev4=%scan(&posspks,&l);
%if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then %do; %if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then %do;
/* check for four level uniqueness */ /* check for four level uniqueness */
proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4) out=&tmpds noduprec; proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4)
out=&tmpds noduprec;
by _all_; by _all_;
run; run;
%if %mf_nobs(&tmpds)=&rows %then %do; %if %mf_nobs(&tmpds)=&rows %then %do;
@@ -233,7 +239,8 @@
%let lev5=%scan(&posspks,&m); %let lev5=%scan(&posspks,&m);
%if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then %do; %if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then %do;
/* check for four level uniqueness */ /* check for four level uniqueness */
proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5) out=&tmpds noduprec; proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5)
out=&tmpds noduprec;
by _all_; by _all_;
run; run;
%if %mf_nobs(&tmpds)=&rows %then %do; %if %mf_nobs(&tmpds)=&rows %then %do;
@@ -282,7 +289,8 @@
run; run;
%if %mf_nobs(&tmpds)=&rows %then %do; %if %mf_nobs(&tmpds)=&rows %then %do;
proc sql; proc sql;
insert into &outds values("&lev1 &lev2 &lev3 &lev4 &lev5 &lev6"); insert into &outds
values("&lev1 &lev2 &lev3 &lev4 &lev5 &lev6");
%if %mf_nobs(&outds) ge &max_guesses %then %do; %if %mf_nobs(&outds) ge &max_guesses %then %do;
%put &sysmacroname: Max PKs reached at Level 6 for &baseds; %put &sysmacroname: Max PKs reached at Level 6 for &baseds;
%return; %return;