@sasjs/core 5.7.1 → 5.7.2
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/base/mp_derivedvars.sas +80 -66
- package/package.json +1 -1
package/base/mp_derivedvars.sas
CHANGED
|
@@ -318,58 +318,64 @@ create table work.&ds_self. as
|
|
|
318
318
|
where name=dep_nm;
|
|
319
319
|
quit;
|
|
320
320
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
,
|
|
326
|
-
|
|
327
|
-
run;
|
|
328
|
-
%mp_abort(iftrue=1,mac=&sysmacroname,msg=%superq(derived_err))
|
|
329
|
-
%end;
|
|
321
|
+
data _null_;
|
|
322
|
+
set work.&ds_baddep.(obs=1);
|
|
323
|
+
call symputx('derived_err'
|
|
324
|
+
,cats(name,': VAR_DEPS lists ',dep_nm
|
|
325
|
+
,', which is not a column of the table or a derived variable'));
|
|
326
|
+
run;
|
|
330
327
|
|
|
331
|
-
%
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
run;
|
|
336
|
-
%mp_abort(iftrue=1,mac=&sysmacroname,msg=%superq(derived_err))
|
|
337
|
-
%end;
|
|
328
|
+
%mp_abort(iftrue= (0 < %mf_nobs(work.&ds_baddep.))
|
|
329
|
+
,mac=&sysmacroname
|
|
330
|
+
,msg=%superq(derived_err)
|
|
331
|
+
)
|
|
338
332
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
,cats(name,': VAR_LOGIC references ',dep_nm
|
|
344
|
-
,', which is not in VAR_DEPS'));
|
|
345
|
-
run;
|
|
346
|
-
%mp_abort(iftrue=1,mac=&sysmacroname,msg=%superq(derived_err))
|
|
347
|
-
%end;
|
|
333
|
+
data _null_;
|
|
334
|
+
set work.&ds_self.(obs=1);
|
|
335
|
+
call symputx('derived_err',cats(name,': VAR_DEPS may not list itself'));
|
|
336
|
+
run;
|
|
348
337
|
|
|
349
|
-
%
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
,cats(name,': VAR_DEPS lists ',dep_nm
|
|
354
|
-
,', which VAR_LOGIC does not reference'));
|
|
355
|
-
run;
|
|
356
|
-
%mp_abort(iftrue=1,mac=&sysmacroname,msg=%superq(derived_err))
|
|
357
|
-
%end;
|
|
338
|
+
%mp_abort(iftrue= (0 < %mf_nobs(work.&ds_self.))
|
|
339
|
+
,mac=&sysmacroname
|
|
340
|
+
,msg=%superq(derived_err)
|
|
341
|
+
)
|
|
358
342
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
343
|
+
data _null_;
|
|
344
|
+
set work.&ds_undecl.(obs=1);
|
|
345
|
+
call symputx('derived_err'
|
|
346
|
+
,cats(name,': VAR_LOGIC references ',dep_nm
|
|
347
|
+
,', which is not in VAR_DEPS'));
|
|
348
|
+
run;
|
|
349
|
+
|
|
350
|
+
%mp_abort(iftrue= (0 < %mf_nobs(work.&ds_undecl.))
|
|
351
|
+
,mac=&sysmacroname
|
|
352
|
+
,msg=%superq(derived_err)
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
data _null_;
|
|
356
|
+
set work.&ds_stale.(obs=1);
|
|
357
|
+
call symputx('derived_err'
|
|
358
|
+
,cats(name,': VAR_DEPS lists ',dep_nm
|
|
359
|
+
,', which VAR_LOGIC does not reference'));
|
|
360
|
+
run;
|
|
361
|
+
|
|
362
|
+
%mp_abort(iftrue= (0 < %mf_nobs(work.&ds_stale.))
|
|
363
|
+
,mac=&sysmacroname
|
|
364
|
+
,msg=%superq(derived_err)
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
data _null_;
|
|
368
|
+
set work.&ds_bad.;
|
|
369
|
+
putlog 'ERR' 'OR: derived variable config: ' name= reason=;
|
|
370
|
+
run;
|
|
371
|
+
data _null_;
|
|
372
|
+
set work.&ds_bad.(obs=1);
|
|
373
|
+
call symputx('derived_err',cats(name,': ',reason));
|
|
374
|
+
run;
|
|
375
|
+
%mp_abort(iftrue= (0 < %mf_nobs(work.&ds_bad.))
|
|
376
|
+
,mac=&sysmacroname
|
|
377
|
+
,msg=%str(Invalid derived variable configuration - &derived_err)
|
|
378
|
+
)
|
|
373
379
|
|
|
374
380
|
/**
|
|
375
381
|
* Dependency order. The edges are between derived variables only - a
|
|
@@ -397,6 +403,7 @@ run;
|
|
|
397
403
|
|
|
398
404
|
%let left=%mf_nobs(work.&ds_todo.);
|
|
399
405
|
%let nplaced=0;
|
|
406
|
+
%let cyc_found=0;
|
|
400
407
|
|
|
401
408
|
%do %while (&left>0);
|
|
402
409
|
proc sql;
|
|
@@ -440,30 +447,37 @@ run;
|
|
|
440
447
|
%end;
|
|
441
448
|
%end;
|
|
442
449
|
%end;
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
450
|
+
/* leave the loop before aborting - an abort cancels the step, and the
|
|
451
|
+
loop would re-enter with the ready count still zero */
|
|
452
|
+
%let cyc_found=1;
|
|
453
|
+
%let left=0;
|
|
447
454
|
%end;
|
|
448
455
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
456
|
+
%if &cyc_found=0 %then %do;
|
|
457
|
+
/* seq carries the dependency order - the placement rounds are not name
|
|
458
|
+
ordered, so the final merge must not rely on by name alone */
|
|
459
|
+
data work.&ds_ready.;
|
|
460
|
+
set work.&ds_ready.;
|
|
461
|
+
seq=_n_+&nplaced;
|
|
462
|
+
run;
|
|
463
|
+
proc append base=work.&ds_placed. data=work.&ds_ready. force;
|
|
464
|
+
run;
|
|
465
|
+
%let nplaced=%eval(&nplaced+&nready);
|
|
458
466
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
467
|
+
proc sql;
|
|
468
|
+
delete from work.&ds_todo.
|
|
469
|
+
where name in (select name from work.&ds_ready.);
|
|
470
|
+
quit;
|
|
463
471
|
|
|
464
|
-
|
|
472
|
+
%let left=%mf_nobs(work.&ds_todo.);
|
|
473
|
+
%end;
|
|
465
474
|
%end;
|
|
466
475
|
|
|
476
|
+
%mp_abort(iftrue= (&cyc_found=1)
|
|
477
|
+
,mac=&sysmacroname
|
|
478
|
+
,msg=%str(VAR_DEPS contains a cycle: &cyc_path)
|
|
479
|
+
)
|
|
480
|
+
|
|
467
481
|
proc sort data=work.&ds_placed.;
|
|
468
482
|
by name;
|
|
469
483
|
run;
|
package/package.json
CHANGED