@sasjs/core 3.12.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/base/mf_abort.sas +1 -1
- package/base/mf_dedup.sas +0 -1
- package/base/mf_existvar.sas +4 -4
- package/base/mf_getfilesize.sas +31 -14
- package/base/mf_wordsinstr1andstr2.sas +0 -1
- package/base/mf_wordsinstr1butnotstr2.sas +5 -5
- package/base/mp_abort.sas +3 -2
- package/base/mp_assertdsobs.sas +8 -9
- package/base/mp_assertscope.sas +39 -14
- package/base/mp_coretable.sas +27 -1
- package/base/mp_createwebservice.sas +10 -8
- package/base/mp_csv2ds.sas +0 -4
- package/base/mp_deletefolder.sas +1 -0
- package/base/mp_dirlist.sas +9 -2
- package/base/mp_ds2csv.sas +119 -14
- package/base/mp_ds2squeeze.sas +120 -0
- package/base/mp_getmaxvarlengths.sas +51 -18
- package/base/mp_guesspk.sas +245 -225
- package/base/mp_init.sas +39 -32
- package/base/mp_jsonout.sas +9 -6
- package/base/mp_stackdiffs.sas +592 -0
- package/base/mp_storediffs.sas +11 -29
- package/base/mp_testservice.sas +25 -11
- package/fcmp/mcf_getfmttype.sas +110 -0
- package/fcmp/mcf_init.sas +44 -0
- package/fcmp/mcf_length.sas +9 -3
- package/fcmp/mcf_stpsrv_header.sas +6 -2
- package/fcmp/mcf_string2file.sas +9 -0
- package/meta/mm_createstp.sas +1 -0
- package/meta/mm_createwebservice.sas +10 -7
- package/meta/mm_getgroupmembers.sas +15 -8
- package/meta/mm_getservercontexts.sas +11 -4
- package/meta/mm_updatestpsourcecode.sas +0 -11
- package/meta/mm_webout.sas +1 -1
- package/package.json +1 -1
- package/server/ms_webout.sas +1 -1
- package/viya/mv_createwebservice.sas +10 -7
- package/viya/mv_deletefoldermember.sas +1 -0
- package/viya/mv_deletejes.sas +1 -0
- package/viya/mv_webout.sas +1 -1
- package/viya/mv_getaccesstoken.sas +0 -32
- package/viya/mv_getapptoken.sas +0 -23
- package/viya/mv_getrefreshtoken.sas +0 -33
package/base/mp_guesspk.sas
CHANGED
|
@@ -17,16 +17,21 @@
|
|
|
17
17
|
%inc mc;
|
|
18
18
|
%mp_guesspk(sashelp.class,outds=classpks)
|
|
19
19
|
|
|
20
|
-
@param baseds The dataset to analyse
|
|
21
|
-
@param outds= The output dataset to contain the possible PKs
|
|
22
|
-
@param max_guesses= (3) The total number of possible primary keys to
|
|
23
|
-
A table may have multiple unlikely PKs, so no need to list them
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
@param [in] baseds The dataset to analyse
|
|
21
|
+
@param [out] outds= The output dataset to contain the possible PKs
|
|
22
|
+
@param [in] max_guesses= (3) The total number of possible primary keys to
|
|
23
|
+
generate. A table may have multiple (unlikely) PKs, so no need to list them
|
|
24
|
+
all.
|
|
25
|
+
@param [in] min_rows= (5) The minimum number of rows a table should have in
|
|
26
|
+
order to try and guess the PK.
|
|
27
|
+
@param [in] ignore_cols (0) Space seperated list of columns which you are
|
|
28
|
+
sure are not part of the primary key (helps to avoid false positives)
|
|
29
|
+
@param [in] mdebug= Set to 1 to enable DEBUG messages and preserve outputs
|
|
26
30
|
|
|
27
31
|
<h4> SAS Macros </h4>
|
|
28
32
|
@li mf_getvarlist.sas
|
|
29
33
|
@li mf_getuniquename.sas
|
|
34
|
+
@li mf_wordsInstr1butnotstr2.sas
|
|
30
35
|
@li mf_nobs.sas
|
|
31
36
|
|
|
32
37
|
<h4> Related Macros </h4>
|
|
@@ -38,179 +43,226 @@
|
|
|
38
43
|
**/
|
|
39
44
|
|
|
40
45
|
%macro mp_guesspk(baseds
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
,outds=mp_guesspk
|
|
47
|
+
,max_guesses=3
|
|
48
|
+
,min_rows=5
|
|
49
|
+
,ignore_cols=0
|
|
50
|
+
,mdebug=0
|
|
44
51
|
)/*/STORE SOURCE*/;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
%
|
|
48
|
-
%
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
%
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
%
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
52
|
+
%local dbg;
|
|
53
|
+
%if &mdebug=1 %then %do;
|
|
54
|
+
%put &sysmacroname entry vars:;
|
|
55
|
+
%put _local_;
|
|
56
|
+
%end;
|
|
57
|
+
%else %let dbg=*;
|
|
58
|
+
|
|
59
|
+
/* declare local vars */
|
|
60
|
+
%local var vars vcnt i j k l tmpvar tmpds rows posspks ppkcnt;
|
|
61
|
+
%let vars=%upcase(%mf_getvarlist(&baseds));
|
|
62
|
+
%let vars=%mf_wordsInStr1ButNotStr2(str1=&vars,str2=%upcase(&ignore_cols));
|
|
63
|
+
%let vcnt=%sysfunc(countw(&vars));
|
|
64
|
+
|
|
65
|
+
%if &vcnt=0 %then %do;
|
|
66
|
+
%put &sysmacroname: &baseds has no variables! Exiting.;
|
|
67
|
+
%return;
|
|
68
|
+
%end;
|
|
69
|
+
|
|
70
|
+
/* get null count and row count */
|
|
71
|
+
%let tmpvar=%mf_getuniquename();
|
|
72
|
+
proc sql noprint;
|
|
73
|
+
create table _data_ as select
|
|
74
|
+
count(*) as &tmpvar
|
|
75
|
+
%do i=1 %to &vcnt;
|
|
76
|
+
%let var=%scan(&vars,&i);
|
|
77
|
+
,sum(case when &var is missing then 1 else 0 end) as &var
|
|
78
|
+
%end;
|
|
79
|
+
from &baseds;
|
|
80
|
+
|
|
81
|
+
/* transpose table and scan for not null cols */
|
|
82
|
+
proc transpose;
|
|
83
|
+
data _null_;
|
|
84
|
+
set &syslast end=last;
|
|
85
|
+
length vars $32767;
|
|
86
|
+
retain vars ;
|
|
87
|
+
if _name_="&tmpvar" then call symputx('rows',col1,'l');
|
|
88
|
+
else if col1=0 then vars=catx(' ',vars,_name_);
|
|
89
|
+
if last then call symputx('posspks',vars,'l');
|
|
90
|
+
run;
|
|
91
|
+
|
|
92
|
+
%let ppkcnt=%sysfunc(countw(&posspks));
|
|
93
|
+
%if &ppkcnt=0 %then %do;
|
|
94
|
+
%put &sysmacroname: &baseds has no non-missing variables! Exiting.;
|
|
95
|
+
%return;
|
|
96
|
+
%end;
|
|
97
|
+
|
|
98
|
+
proc sort data=&baseds(keep=&posspks) out=_data_ noduprec;
|
|
99
|
+
by _all_;
|
|
100
|
+
run;
|
|
101
|
+
%local pkds; %let pkds=&syslast;
|
|
102
|
+
|
|
103
|
+
%if &rows > %mf_nobs(&pkds) %then %do;
|
|
104
|
+
%put &sysmacroname: &baseds has no combination of unique records! Exiting.;
|
|
105
|
+
%return;
|
|
106
|
+
%end;
|
|
107
|
+
|
|
108
|
+
/* now check cardinality */
|
|
109
|
+
proc sql noprint;
|
|
110
|
+
create table _data_ as select
|
|
111
|
+
%do i=1 %to &ppkcnt;
|
|
112
|
+
%let var=%scan(&posspks,&i);
|
|
113
|
+
count(distinct &var) as &var
|
|
114
|
+
%if &i<&ppkcnt %then ,;
|
|
115
|
+
%end;
|
|
116
|
+
from &pkds;
|
|
117
|
+
|
|
118
|
+
/* transpose and sort by cardinality */
|
|
119
|
+
proc transpose;
|
|
120
|
+
proc sort; by descending col1;
|
|
121
|
+
run;
|
|
122
|
+
|
|
123
|
+
/* create initial PK list and re-order posspks list */
|
|
124
|
+
data &outds(keep=pkguesses);
|
|
125
|
+
length pkguesses $5000 vars $5000;
|
|
126
|
+
set &syslast end=last;
|
|
127
|
+
retain vars ;
|
|
128
|
+
vars=catx(' ',vars,_name_);
|
|
129
|
+
if col1=&rows then do;
|
|
130
|
+
pkguesses=_name_;
|
|
131
|
+
output;
|
|
132
|
+
end;
|
|
133
|
+
if last then call symputx('posspks',vars,'l');
|
|
134
|
+
run;
|
|
135
|
+
|
|
136
|
+
%if %mf_nobs(&outds) ge &max_guesses %then %do;
|
|
137
|
+
%put &sysmacroname: %mf_nobs(&outds) possible primary key values found;
|
|
138
|
+
%return;
|
|
139
|
+
%end;
|
|
140
|
+
|
|
141
|
+
%if &ppkcnt=1 %then %do;
|
|
142
|
+
%put &sysmacroname: No more PK guess possible;
|
|
143
|
+
%return;
|
|
144
|
+
%end;
|
|
145
|
+
|
|
146
|
+
/* begin scanning for uniques on pairs of PKs */
|
|
147
|
+
%let tmpds=%mf_getuniquename();
|
|
148
|
+
%local lev1 lev2;
|
|
149
|
+
%do i=1 %to &ppkcnt;
|
|
150
|
+
%let lev1=%scan(&posspks,&i);
|
|
151
|
+
%do j=2 %to &ppkcnt;
|
|
152
|
+
%let lev2=%scan(&posspks,&j);
|
|
153
|
+
%if &lev1 ne &lev2 %then %do;
|
|
154
|
+
/* check for two level uniqueness */
|
|
155
|
+
proc sort data=&pkds(keep=&lev1 &lev2) out=&tmpds noduprec;
|
|
156
|
+
by _all_;
|
|
157
|
+
run;
|
|
158
|
+
%if %mf_nobs(&tmpds)=&rows %then %do;
|
|
159
|
+
proc sql;
|
|
160
|
+
insert into &outds values("&lev1 &lev2");
|
|
161
|
+
%if %mf_nobs(&outds) ge &max_guesses %then %do;
|
|
162
|
+
%put &sysmacroname: Max PKs reached at Level 2 for &baseds;
|
|
163
|
+
%goto exit;
|
|
164
|
+
%end;
|
|
165
|
+
%end;
|
|
166
|
+
%end;
|
|
130
167
|
%end;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
%
|
|
135
|
-
%
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
168
|
+
%end;
|
|
169
|
+
|
|
170
|
+
%if &ppkcnt=2 %then %do;
|
|
171
|
+
%put &sysmacroname: No more PK guess possible;
|
|
172
|
+
%goto exit;
|
|
173
|
+
%end;
|
|
174
|
+
|
|
175
|
+
/* begin scanning for uniques on PK triplets */
|
|
176
|
+
%local lev3;
|
|
177
|
+
%do i=1 %to &ppkcnt;
|
|
178
|
+
%let lev1=%scan(&posspks,&i);
|
|
179
|
+
%do j=2 %to &ppkcnt;
|
|
180
|
+
%let lev2=%scan(&posspks,&j);
|
|
181
|
+
%if &lev1 ne &lev2 %then %do k=3 %to &ppkcnt;
|
|
182
|
+
%let lev3=%scan(&posspks,&k);
|
|
183
|
+
%if &lev1 ne &lev3 and &lev2 ne &lev3 %then %do;
|
|
184
|
+
/* check for three level uniqueness */
|
|
185
|
+
proc sort data=&pkds(keep=&lev1 &lev2 &lev3) out=&tmpds noduprec;
|
|
142
186
|
by _all_;
|
|
143
187
|
run;
|
|
144
188
|
%if %mf_nobs(&tmpds)=&rows %then %do;
|
|
145
189
|
proc sql;
|
|
146
|
-
insert into &outds values("&lev1 &lev2");
|
|
190
|
+
insert into &outds values("&lev1 &lev2 &lev3");
|
|
147
191
|
%if %mf_nobs(&outds) ge &max_guesses %then %do;
|
|
148
|
-
%put &sysmacroname: Max PKs reached at Level
|
|
149
|
-
%
|
|
192
|
+
%put &sysmacroname: Max PKs reached at Level 3 for &baseds;
|
|
193
|
+
%goto exit;
|
|
150
194
|
%end;
|
|
151
195
|
%end;
|
|
152
196
|
%end;
|
|
153
197
|
%end;
|
|
154
198
|
%end;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
%
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
199
|
+
%end;
|
|
200
|
+
|
|
201
|
+
%if &ppkcnt=3 %then %do;
|
|
202
|
+
%put &sysmacroname: No more PK guess possible;
|
|
203
|
+
%goto exit;
|
|
204
|
+
%end;
|
|
205
|
+
|
|
206
|
+
/* scan for uniques on up to 4 PK fields */
|
|
207
|
+
%local lev4;
|
|
208
|
+
%do i=1 %to &ppkcnt;
|
|
209
|
+
%let lev1=%scan(&posspks,&i);
|
|
210
|
+
%do j=2 %to &ppkcnt;
|
|
211
|
+
%let lev2=%scan(&posspks,&j);
|
|
212
|
+
%if &lev1 ne &lev2 %then %do k=3 %to &ppkcnt;
|
|
213
|
+
%let lev3=%scan(&posspks,&k);
|
|
214
|
+
%if &lev1 ne &lev3 and &lev2 ne &lev3 %then %do l=4 %to &ppkcnt;
|
|
215
|
+
%let lev4=%scan(&posspks,&l);
|
|
216
|
+
%if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then %do;
|
|
217
|
+
/* check for four level uniqueness */
|
|
218
|
+
proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4)
|
|
219
|
+
out=&tmpds noduprec;
|
|
172
220
|
by _all_;
|
|
173
221
|
run;
|
|
174
222
|
%if %mf_nobs(&tmpds)=&rows %then %do;
|
|
175
223
|
proc sql;
|
|
176
|
-
insert into &outds values("&lev1 &lev2 &lev3");
|
|
224
|
+
insert into &outds values("&lev1 &lev2 &lev3 &lev4");
|
|
177
225
|
%if %mf_nobs(&outds) ge &max_guesses %then %do;
|
|
178
|
-
%put &sysmacroname: Max PKs reached at Level
|
|
179
|
-
%
|
|
226
|
+
%put &sysmacroname: Max PKs reached at Level 4 for &baseds;
|
|
227
|
+
%goto exit;
|
|
180
228
|
%end;
|
|
181
229
|
%end;
|
|
182
230
|
%end;
|
|
183
231
|
%end;
|
|
184
232
|
%end;
|
|
185
233
|
%end;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
%
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
234
|
+
%end;
|
|
235
|
+
|
|
236
|
+
%if &ppkcnt=4 %then %do;
|
|
237
|
+
%put &sysmacroname: No more PK guess possible;
|
|
238
|
+
%goto exit;
|
|
239
|
+
%end;
|
|
240
|
+
|
|
241
|
+
/* scan for uniques on up to 4 PK fields */
|
|
242
|
+
%local lev5 m;
|
|
243
|
+
%do i=1 %to &ppkcnt;
|
|
244
|
+
%let lev1=%scan(&posspks,&i);
|
|
245
|
+
%do j=2 %to &ppkcnt;
|
|
246
|
+
%let lev2=%scan(&posspks,&j);
|
|
247
|
+
%if &lev1 ne &lev2 %then %do k=3 %to &ppkcnt;
|
|
248
|
+
%let lev3=%scan(&posspks,&k);
|
|
249
|
+
%if &lev1 ne &lev3 and &lev2 ne &lev3 %then %do l=4 %to &ppkcnt;
|
|
250
|
+
%let lev4=%scan(&posspks,&l);
|
|
251
|
+
%if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then
|
|
252
|
+
%do m=5 %to &ppkcnt;
|
|
253
|
+
%let lev5=%scan(&posspks,&m);
|
|
254
|
+
%if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then %do;
|
|
203
255
|
/* check for four level uniqueness */
|
|
204
|
-
proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4)
|
|
256
|
+
proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5)
|
|
205
257
|
out=&tmpds noduprec;
|
|
206
258
|
by _all_;
|
|
207
259
|
run;
|
|
208
260
|
%if %mf_nobs(&tmpds)=&rows %then %do;
|
|
209
261
|
proc sql;
|
|
210
|
-
insert into &outds values("&lev1 &lev2 &lev3 &lev4");
|
|
262
|
+
insert into &outds values("&lev1 &lev2 &lev3 &lev4 &lev5");
|
|
211
263
|
%if %mf_nobs(&outds) ge &max_guesses %then %do;
|
|
212
|
-
%put &sysmacroname: Max PKs reached at Level
|
|
213
|
-
%
|
|
264
|
+
%put &sysmacroname: Max PKs reached at Level 5 for &baseds;
|
|
265
|
+
%goto exit;
|
|
214
266
|
%end;
|
|
215
267
|
%end;
|
|
216
268
|
%end;
|
|
@@ -218,83 +270,44 @@
|
|
|
218
270
|
%end;
|
|
219
271
|
%end;
|
|
220
272
|
%end;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
%
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
273
|
+
%end;
|
|
274
|
+
|
|
275
|
+
%if &ppkcnt=5 %then %do;
|
|
276
|
+
%put &sysmacroname: No more PK guess possible;
|
|
277
|
+
%goto exit;
|
|
278
|
+
%end;
|
|
279
|
+
|
|
280
|
+
/* scan for uniques on up to 4 PK fields */
|
|
281
|
+
%local lev6 n;
|
|
282
|
+
%do i=1 %to &ppkcnt;
|
|
283
|
+
%let lev1=%scan(&posspks,&i);
|
|
284
|
+
%do j=2 %to &ppkcnt;
|
|
285
|
+
%let lev2=%scan(&posspks,&j);
|
|
286
|
+
%if &lev1 ne &lev2 %then %do k=3 %to &ppkcnt;
|
|
287
|
+
%let lev3=%scan(&posspks,&k);
|
|
288
|
+
%if &lev1 ne &lev3 and &lev2 ne &lev3 %then %do l=4 %to &ppkcnt;
|
|
289
|
+
%let lev4=%scan(&posspks,&l);
|
|
290
|
+
%if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then
|
|
291
|
+
%do m=5 %to &ppkcnt;
|
|
292
|
+
%let lev5=%scan(&posspks,&m);
|
|
293
|
+
%if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5
|
|
294
|
+
%then %do n=6 %to &ppkcnt;
|
|
295
|
+
%let lev6=%scan(&posspks,&n);
|
|
296
|
+
%if &lev1 ne &lev6 & &lev2 ne &lev6 & &lev3 ne &lev6
|
|
297
|
+
& &lev4 ne &lev6 & &lev5 ne &lev6 %then
|
|
298
|
+
%do;
|
|
241
299
|
/* check for four level uniqueness */
|
|
242
|
-
proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5)
|
|
243
|
-
|
|
300
|
+
proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5 &lev6)
|
|
301
|
+
out=&tmpds noduprec;
|
|
244
302
|
by _all_;
|
|
245
303
|
run;
|
|
246
304
|
%if %mf_nobs(&tmpds)=&rows %then %do;
|
|
247
305
|
proc sql;
|
|
248
|
-
insert into &outds
|
|
306
|
+
insert into &outds
|
|
307
|
+
values("&lev1 &lev2 &lev3 &lev4 &lev5 &lev6");
|
|
249
308
|
%if %mf_nobs(&outds) ge &max_guesses %then %do;
|
|
250
|
-
%put &sysmacroname: Max PKs reached at Level
|
|
251
|
-
%
|
|
252
|
-
%end;
|
|
253
|
-
%end;
|
|
254
|
-
%end;
|
|
255
|
-
%end;
|
|
256
|
-
%end;
|
|
257
|
-
%end;
|
|
258
|
-
%end;
|
|
259
|
-
%end;
|
|
260
|
-
|
|
261
|
-
%if &ppkcnt=5 %then %do;
|
|
262
|
-
%put &sysmacroname: No more PK guess possible;
|
|
263
|
-
%return;
|
|
264
|
-
%end;
|
|
265
|
-
|
|
266
|
-
/* scan for uniques on up to 4 PK fields */
|
|
267
|
-
%local lev6 n;
|
|
268
|
-
%do i=1 %to &ppkcnt;
|
|
269
|
-
%let lev1=%scan(&posspks,&i);
|
|
270
|
-
%do j=2 %to &ppkcnt;
|
|
271
|
-
%let lev2=%scan(&posspks,&j);
|
|
272
|
-
%if &lev1 ne &lev2 %then %do k=3 %to &ppkcnt;
|
|
273
|
-
%let lev3=%scan(&posspks,&k);
|
|
274
|
-
%if &lev1 ne &lev3 and &lev2 ne &lev3 %then %do l=4 %to &ppkcnt;
|
|
275
|
-
%let lev4=%scan(&posspks,&l);
|
|
276
|
-
%if &lev1 ne &lev4 and &lev2 ne &lev4 and &lev3 ne &lev4 %then
|
|
277
|
-
%do m=5 %to &ppkcnt;
|
|
278
|
-
%let lev5=%scan(&posspks,&m);
|
|
279
|
-
%if &lev1 ne &lev5 & &lev2 ne &lev5 & &lev3 ne &lev5 & &lev4 ne &lev5 %then
|
|
280
|
-
%do n=6 %to &ppkcnt;
|
|
281
|
-
%let lev6=%scan(&posspks,&n);
|
|
282
|
-
%if &lev1 ne &lev6 & &lev2 ne &lev6 & &lev3 ne &lev6
|
|
283
|
-
& &lev4 ne &lev6 & &lev5 ne &lev6 %then
|
|
284
|
-
%do;
|
|
285
|
-
/* check for four level uniqueness */
|
|
286
|
-
proc sort data=&pkds(keep=&lev1 &lev2 &lev3 &lev4 &lev5 &lev6)
|
|
287
|
-
out=&tmpds noduprec;
|
|
288
|
-
by _all_;
|
|
289
|
-
run;
|
|
290
|
-
%if %mf_nobs(&tmpds)=&rows %then %do;
|
|
291
|
-
proc sql;
|
|
292
|
-
insert into &outds
|
|
293
|
-
values("&lev1 &lev2 &lev3 &lev4 &lev5 &lev6");
|
|
294
|
-
%if %mf_nobs(&outds) ge &max_guesses %then %do;
|
|
295
|
-
%put &sysmacroname: Max PKs reached at Level 6 for &baseds;
|
|
296
|
-
%return;
|
|
297
|
-
%end;
|
|
309
|
+
%put &sysmacroname: Max PKs reached at Level 6 for &baseds;
|
|
310
|
+
%goto exit;
|
|
298
311
|
%end;
|
|
299
312
|
%end;
|
|
300
313
|
%end;
|
|
@@ -303,10 +316,17 @@
|
|
|
303
316
|
%end;
|
|
304
317
|
%end;
|
|
305
318
|
%end;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
%
|
|
319
|
+
%end;
|
|
320
|
+
|
|
321
|
+
%if &ppkcnt=6 %then %do;
|
|
322
|
+
%put &sysmacroname: No more PK guess possible;
|
|
323
|
+
%goto exit;
|
|
324
|
+
%end;
|
|
325
|
+
|
|
326
|
+
%exit:
|
|
327
|
+
%if &mdebug=0 %then %do;
|
|
328
|
+
proc sql;
|
|
329
|
+
drop table &tmpds;
|
|
330
|
+
%end;
|
|
311
331
|
|
|
312
332
|
%mend mp_guesspk;
|
package/base/mp_init.sas
CHANGED
|
@@ -33,37 +33,44 @@
|
|
|
33
33
|
%macro mp_init(prefix=SASJS
|
|
34
34
|
)/*/STORE SOURCE*/;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
36
|
+
%if %symexist(SASJS_PREFIX) %then %return; /* only run once */
|
|
37
|
+
|
|
38
|
+
%global
|
|
39
|
+
SASJS_PREFIX /* the ONLY hard-coded global macro variable in SASjs */
|
|
40
|
+
&prefix._FUNCTIONS /* used in mcf_init() to track core function compilation */
|
|
41
|
+
&prefix._INIT_NUM /* initialisation time as numeric */
|
|
42
|
+
&prefix._INIT_DTTM /* initialisation time in E8601DT26.6 format */
|
|
43
|
+
&prefix.WORK /* avoid typing %sysfunc(pathname(work)) every time */
|
|
44
|
+
;
|
|
45
|
+
|
|
46
|
+
%let sasjs_prefix=&prefix;
|
|
47
|
+
|
|
48
|
+
data _null_;
|
|
49
|
+
dttm=datetime();
|
|
50
|
+
call symputx("&sasjs_prefix._init_num",dttm,'g');
|
|
51
|
+
call symputx("&sasjs_prefix._init_dttm",put(dttm,E8601DT26.6),'g');
|
|
52
|
+
call symputx("&sasjs_prefix.work",pathname('WORK'),'g');
|
|
53
|
+
run;
|
|
54
|
+
|
|
55
|
+
options
|
|
56
|
+
compress=CHAR /* default is none so ensure we have something! */
|
|
57
|
+
datastmtchk=ALLKEYWORDS /* protection from overwriting input datasets */
|
|
58
|
+
errorcheck=STRICT /* catch errs in libname/filename statements */
|
|
59
|
+
fmterr /* ensure err when a format cannot be found */
|
|
60
|
+
mergenoby=%str(ERR)OR /* throw err when a merge has no BY variables */
|
|
61
|
+
missing=. /* changing this can cause hard to detect errs */
|
|
62
|
+
noquotelenmax /* avoid warnings for long strings */
|
|
63
|
+
noreplace /* avoid overwriting permanent datasets */
|
|
64
|
+
ps=max /* reduce log size slightly */
|
|
65
|
+
ls=max /* reduce log even more and avoid word truncation */
|
|
66
|
+
validmemname=COMPATIBLE /* avoid special characters etc in table names */
|
|
67
|
+
validvarname=V7 /* avoid special characters etc in variable names */
|
|
68
|
+
varinitchk=%str(ERR)OR /* avoid data mistakes from variable name typos */
|
|
69
|
+
varlenchk=%str(ERR)OR /* fail hard if truncation (data loss) can result */
|
|
70
|
+
%if %substr(&sysver,1,1) ne 4 %then %do;
|
|
71
|
+
noautocorrect /* disallow misspelled procedure names */
|
|
72
|
+
dsoptions=note2err /* undocumented - convert bad NOTEs to ERRs */
|
|
73
|
+
%end;
|
|
74
|
+
;
|
|
68
75
|
|
|
69
76
|
%mend mp_init;
|