@sasjs/core 5.7.0 → 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 +84 -67
- package/package.json +1 -1
package/base/mp_derivedvars.sas
CHANGED
|
@@ -148,7 +148,10 @@ run;
|
|
|
148
148
|
|
|
149
149
|
data work.&ds_cfg.;
|
|
150
150
|
set &control;
|
|
151
|
-
%
|
|
151
|
+
/* %superq, because a filter can legitimately contain quotes - a datetime
|
|
152
|
+
literal such as "21OCT2026:09:00:00"dt is the usual case, and quoting it
|
|
153
|
+
again inside a %if condition breaks the evaluation */
|
|
154
|
+
%if %superq(where) ne 0 %then %do;
|
|
152
155
|
where &where;
|
|
153
156
|
%end;
|
|
154
157
|
where also upcase(libref)="%upcase(%scan(&libds,1,.))"
|
|
@@ -315,58 +318,64 @@ create table work.&ds_self. as
|
|
|
315
318
|
where name=dep_nm;
|
|
316
319
|
quit;
|
|
317
320
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
,
|
|
323
|
-
|
|
324
|
-
run;
|
|
325
|
-
%mp_abort(iftrue=1,mac=&sysmacroname,msg=%superq(derived_err))
|
|
326
|
-
%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;
|
|
327
327
|
|
|
328
|
-
%
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
run;
|
|
333
|
-
%mp_abort(iftrue=1,mac=&sysmacroname,msg=%superq(derived_err))
|
|
334
|
-
%end;
|
|
328
|
+
%mp_abort(iftrue= (0 < %mf_nobs(work.&ds_baddep.))
|
|
329
|
+
,mac=&sysmacroname
|
|
330
|
+
,msg=%superq(derived_err)
|
|
331
|
+
)
|
|
335
332
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
,cats(name,': VAR_LOGIC references ',dep_nm
|
|
341
|
-
,', which is not in VAR_DEPS'));
|
|
342
|
-
run;
|
|
343
|
-
%mp_abort(iftrue=1,mac=&sysmacroname,msg=%superq(derived_err))
|
|
344
|
-
%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;
|
|
345
337
|
|
|
346
|
-
%
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
,cats(name,': VAR_DEPS lists ',dep_nm
|
|
351
|
-
,', which VAR_LOGIC does not reference'));
|
|
352
|
-
run;
|
|
353
|
-
%mp_abort(iftrue=1,mac=&sysmacroname,msg=%superq(derived_err))
|
|
354
|
-
%end;
|
|
338
|
+
%mp_abort(iftrue= (0 < %mf_nobs(work.&ds_self.))
|
|
339
|
+
,mac=&sysmacroname
|
|
340
|
+
,msg=%superq(derived_err)
|
|
341
|
+
)
|
|
355
342
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
+
)
|
|
370
379
|
|
|
371
380
|
/**
|
|
372
381
|
* Dependency order. The edges are between derived variables only - a
|
|
@@ -394,6 +403,7 @@ run;
|
|
|
394
403
|
|
|
395
404
|
%let left=%mf_nobs(work.&ds_todo.);
|
|
396
405
|
%let nplaced=0;
|
|
406
|
+
%let cyc_found=0;
|
|
397
407
|
|
|
398
408
|
%do %while (&left>0);
|
|
399
409
|
proc sql;
|
|
@@ -437,30 +447,37 @@ run;
|
|
|
437
447
|
%end;
|
|
438
448
|
%end;
|
|
439
449
|
%end;
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
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;
|
|
444
454
|
%end;
|
|
445
455
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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);
|
|
455
466
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
467
|
+
proc sql;
|
|
468
|
+
delete from work.&ds_todo.
|
|
469
|
+
where name in (select name from work.&ds_ready.);
|
|
470
|
+
quit;
|
|
460
471
|
|
|
461
|
-
|
|
472
|
+
%let left=%mf_nobs(work.&ds_todo.);
|
|
473
|
+
%end;
|
|
462
474
|
%end;
|
|
463
475
|
|
|
476
|
+
%mp_abort(iftrue= (&cyc_found=1)
|
|
477
|
+
,mac=&sysmacroname
|
|
478
|
+
,msg=%str(VAR_DEPS contains a cycle: &cyc_path)
|
|
479
|
+
)
|
|
480
|
+
|
|
464
481
|
proc sort data=work.&ds_placed.;
|
|
465
482
|
by name;
|
|
466
483
|
run;
|
package/package.json
CHANGED