-
Notifications
You must be signed in to change notification settings - Fork 1
/
Fid_project
1406 lines (1314 loc) · 76.2 KB
/
Fid_project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%macro executeBatchDataMining;
/***************************************************************************************************/
/** The executeBatchDataMining macro finishes data preparation and does the following: ********/
/** 1. Across all the target variables used in the expanded parameter table, the macro ********/
/** examines the relationship between each independent variable and the dependent ********/
/** variable using the remove_badly_behaving_vars macro to find independent variables ********/
/** that either have 0 or > 1.0e+30 values for the Corrected Sum of Squares (CSS). ********/
/** If any such variables are found, they are removed from the analysis. ********/
/** A macro list of acceptable variables is created to use in the next loop for ********/
/** variable reduction. ********/
/** 2. For each row of the expanded parameter table, a variable reduction process is run ********/
/** to eventually produce a final set of 75 variables and potentially significant ********/
/** interactions to be input into a variety of models which based on the target ********/
/** variable type include: ********/
/** Binary Numeric - HPLOGISTIC HPFOREST HPNEURAL ********/
/** Binary Categorical - HPLOGISTIC HPFOREST HPNEURAL ********/
/** Ordinal - HPLOGISTIC HPNEURAL ********/
/** Interval - HPREG HPFOREST HPNEURAL ********/
/** Categorical - HPLOGISTIC(LINK=GLOGIT) HPFOREST HPNEURAL ********/
/** The results of these models are then put into the Model Manager system for future ********/
/** access ********/
/***************************************************************************************************/
%** Capture original options settings, so that debugging can temporarily switch them and then ;
%** return to the original settings. ;
%local original_settings;
%let original_settings = %sysfunc(getoption(mprint))
%sysfunc(getoption(mlogic))
%sysfunc(getoption(symbolgen));
%** Remove large tables remaining from prior runs of the model factory. ;
proc datasets library=gplib;
delete mod_: sub_: alldri_targ:;
run;
%** Parse the list of the tables that will be processed produce table and schema names ;
%let tableCounter = 1;
%let only&tableCounter = gplib.%scan(&tableList,&tableCounter, " ");
%let sonly&tableCounter = &sschema..%scan(&tableList,&tableCounter, " ");
%let table&tableCounter = gplib.mod_%scan(&tableList,&tableCounter," ");
%let ccc&tableCounter = %scan(&tableList,&tableCounter, " ");
%let schema&tableCounter = &sschema..mod_%scan(&tableList,&tableCounter," ");
%let subtable&tableCounter = gplib.sub_%scan(&tableList,&tableCounter, " ");
%let subschema&tableCounter = &sschema..sub_%scan(&tableList,&tableCounter, " ");
%** For each independent table in the list, create a group of macro variables to reference ;
%** each independent table in the list ;
%do %while("&&ccc&tableCounter" NE "");
%** STOP the job if one of the independent variable tables does not exist ;
%if ^%sysfunc(exist(&&only&tableCounter..)) %then %do;
%put **************************************************************************;
%put **************************************************************************;
%put ERROR: &&only&tableCounter.. does not exist;
%put ERROR- NO further checking will be done ;
%put WARNING: Please check existence of all GP tables in the Param_TableList variable.;
%put ERROR: Factory Model Job will now end;
%put **************************************************************************;
%put **************************************************************************;
%abort cancel;
%end;
%** SET up the counter macros for use in the macro do loops ;
%let tableCounter = %eval(&tableCounter + 1);
%let ccc&tableCounter = %scan(&tableList,&tableCounter, " ");
%let only&tableCounter = gplib.%scan(&tableList,&tableCounter, " ");
%let sonly&tableCounter = &sschema..%scan(&tableList,&tableCounter, " ");
%let table&tableCounter = gplib.mod_%scan(&tableList,&tableCounter, " ");
%let schema&tableCounter = &sschema..mod_%scan(&tableList,&tableCounter, " ");
%let subtable&tableCounter = gplib.sub_%scan(&tableList,&tableCounter, " ");
%let subschema&tableCounter = &sschema..sub_%scan(&tableList,&tableCounter, " ");
%** End of loop to create a group of macro variables to reference ;
%end;
%let tableCounter = %eval(&tableCounter - 1);
%put 1 &only1 &table1 &schema1;
%put &tableCounter &&only&tableCounter &&table&tableCounter &&schema&tableCounter;
%** Loop #1 below requires a list of names of dependent variables from the dependent table. ;
%** This step retrieves a constant list, and so is not part of the loop. ;
%** Create that list now, in the form needed for SQL: ;
%** dep.var1, dep.var2, dep.var3, etc. ;
%** Some coding revisions attempted a slightly different style (no longer being used): ;
%** dep."var1", dep."var2", dep."var3", etc. ;
%** When Greenplum uses a list in this style, capitalization matters. The added code needed ;
%** to retrieve the exact spelling including capitalization is left in place below. ;
options MPRINT ;
proc contents data=gplib.&dep_table. out=_contents_dep_table noprint varnum;
run;
%local dependent_varlist
numeric_indeps_kept_comma
var_name
hpvar_name
count
sup_var_name
unsup_var_name;
proc sql noprint;
create table _dependent_variables_needed_ as
select distinct(upcase(dependent_variable)) as upcase_name
from ¶meter_file;
create table _dependents_proper_spelling_ as
select spelling.name
from _dependent_variables_needed_ needed
left join _contents_dep_table spelling
on needed.upcase_name = upcase(spelling.name);
select ('dep.' || strip(name)) into : dependent_varlist
separated by ','
from _dependents_proper_spelling_;
quit;
%local segmentation_varlist;
%if &numattr > 0 %then %do;
data _segmentation_variables_needed_;
length upcase_name $ 32;
%do i=1 %to &numattr;
upcase_name = upcase("&&attr&i");
output;
%end;
run;
proc sql noprint;
%** In theory, a segmentation variable for one model could be the dependent variable for ;
%** another model. Remove any overlap, so the SQL code in Loop #1 below will not attempt ;
%** to retrieve the same variable twice. ;
create table _segmentation_no_overlap_ as
select * from _segmentation_variables_needed_ seg
where not exists (select * from _dependent_variables_needed_ dep
where seg.upcase_name=dep.upcase_name);
create table _segmentation_proper_spelling_ as
select spelling.name
from _segmentation_no_overlap_ needed
left join _contents_dep_table spelling
on needed.upcase_name = upcase(spelling.name);
select ('dep.' || strip(name)) into : segmentation_varlist
separated by ','
from _segmentation_proper_spelling_;
quit;
%end;
proc sql noprint;
select strip(name) into : IdVar
from _contents_dep_table
where strip(upcase(name)) = strip(upcase("&IdVar"));
quit;
options &original_settings;
%** Loop #1 ;
%** For each independent table: ;
%** - remove badly behaving independent variables ;
%** - join with dependent table (needed vars only) ;
%** - subset rows to match dependent table ;
%let iii = 0; /* Counter to replace tabCnt when there are tables with NO valid variables */
%let tot_tab = &tableCounter; /* Counter to replace tableCounterfor tables with NO valid variables */
%do tabCnt = 1 %to &tableCounter; /* Start of Loop #1 */
%let iii = %eval(&iii + 1); /*Increment iii each time tabcnt increments -- may decrement later */
%put Loop #1 beginning iteration #&tabCnt;
%local numeric_indeps_&iii.
numeric_indeps_kept_&iii.
count&iii.;
proc contents data=&&only&iii out= perm.contents_&iii noprint varnum;
run;
proc sql noprint;
select name into :numeric_indeps_&iii. separated by ' '
from perm.contents_&iii where type = 1;
quit;
%** Remove Badly Behaving Independent Variables ;
%remove_badly_behaving_vars (data_in=&&only&iii,
var_list=&&numeric_indeps_&iii..,
removal_reason_dataset=perm.bad_vars_&iii.
);
proc print data=perm.bad_vars_&iii.;
where reason_for_removal > ' ';
var Variable_Name reason_for_removal label css format nmiss;
format label $40.;
title "Badly Behaving Variables being removed from &&only&iii";
run;
%** Create macro variables to hold any variable lists that might be needed. ;
%** Save lists of independent variables NOW, before combining with dependent table. ;
%** This guarantees that lists of independent variables cannot include additional ;
%** dependent variables or segmentation variables from dependent data. ;
proc sql;
select variable_name into : numeric_indeps_kept_&iii separated by ' '
from perm.bad_vars_&iii. where reason_for_removal=' ';
select variable_name into : numeric_indeps_kept_comma separated by ','
from perm.bad_vars_&iii. where reason_for_removal=' ';
quit;
%** For any GP table with all BAD variables, renumber the table list so that the ;
%** misbehaving table is removed from processing. ;
%if &&numeric_indeps_kept_&iii = %then %let tot_tab = %eval(&tot_tab - 1);
%if &&numeric_indeps_kept_&iii = %then %do i = &iii %to &tot_tab;
%let I_1 = %eval(&I + 1);
%let ccc&I = &&ccc&I_1;
%let only&I = &&only&I_1;
%let table&I = &&table&I_1;
%let subtable&I = &&subtable&I_1;
%let sonly&I = &&sonly&I_1;
%let schema&I = &&schema&I_1;
%let subschema&I = &&subschema&I_1;
%end;
%** Join Dependent Variable tables with Independent Variable tables ;
%** Subset the records that match on the ID variable. ;
%** Bring in just the needed variables from the dependent table: ;
%** dependents, ID variable, and segmentation variables. ;
/* create the combined table only if there are dependent variables */
%if &&numeric_indeps_kept_&iii ^= %then %do;
%drop_table_iff (&&schema&iii)
OPTIONS MPRINT;
proc sql;
Connect to Greenplm (server=&server user=&user password=&pwd
database=&database schema="&sschema" );
execute (set gp_autostats_mode='NONE') by Greenplm;
execute ( create table &&schema&iii with (appendonly=true, compresstype=QUICKLZ, OIDS=FALSE) as
select dep.&idVar,
&dependent_varlist,
%if %length(&segmentation_varlist) %then &segmentation_varlist,;
&numeric_indeps_kept_comma
from &sschema..&dep_table. as dep,
&&sonly&iii as indep
where dep.&idVar. = indep.&idVar. DISTRIBUTED BY (&idVar.)) by Greenplm;
execute (analyze &&schema&iii (&idVar. &attrlistc.)) by Greenplm;
quit;
OPTIONS &original_settings;
%end;
/* If a table has NO valid variables, then reduce the counter by one */
%if &&numeric_indeps_kept_&iii = %then %let iii = %eval(&iii - 1);
%put Loop #1 finishing iteration #&tabCnt;
%end; /* end of Loop #1: processing each independent table */
%** Set total tables to be tot_tab. ;
%LET tableCounter = &tot_tab;
%** Loop #2: ;
%** Process each row of parameter table separately ... runs through the end of this macro. ;
%** This loop does: ;
%** 1. The HPREDUCE variable reduction ;
%** 2. Builds the models ;
%** 3. Passes the results to Model Manager ;
%do targCnt = 1 %to &targetVarCounter.;
data work.parameters_expand1;
length segmentation_variables_needed
where_clause $ 1000;
set perm.parameters_expand (firstobs=&targCnt. obs=&targCnt.);
%** For each segmentation variable, determine the subsetting required ;
%if &numattr > 0 %then %do;
array ar_attr{&numattr.} &attrlist.;
do i = 1 to &numattr.;
%** For a segmentation variable that has the key word, 'COMBINED', ignore that segmentation variable ;
%** If segmentation is required, create the subsetting where clause which may go across multiple segmentation variables ;
if upcase(ar_attr{i}) ne 'COMBINED' then do;
segmentation_variables_needed =
strip(segmentation_variables_needed) || ' ' || vname(ar_attr{i});
if where_clause = ' ' then where_clause =
'where ' || vname(ar_attr{i}) || "='" || trim(ar_attr{i}) || "'";
else where_clause = trim(where_clause) ||
' and ' || vname(ar_attr{i}) || "='" || trim(ar_attr{i}) || "'";
end;
end;
%end;
%** Values retrieved from one row of expanded parameter table: ;
%** - Final HPREDUCE HP_Reduce_Stopping_Rule, and threshold ;
%** Acceptable values for HP_Reduce_Stopping_Rule: ;
%** VarExp, MaxEffects, MINVARIANCEINCREMENT ;
%** - WHERE clause for subsetting ;
%** - Target (dependent) variable ;
%** - "Repeat" (Y/N: Can data subset from previous row be re-used for this row?) ;
%** - Sample percent for modeling ;
%** - Event parameter ;
%** - Parameters for each statistical model: ;
%** > HPLOGISTIC 1 ;
%** > HPLOGISTIC 2 ;
%** > HPNEURAL 1 ;
%** > HPNEURAL 2 ;
%** > HPFOREST 1 ;
%** > HPFOREST 2 ;
%** > HPREG 1 ;
%** > HPREG 2 ;
call symputx('dependent_variable', dependent_variable,'G');
call symputx('HP_Reduce_Stopping_Rule', HP_Reduce_Stopping_Rule,'G');
call symputx('HPReduce_Stopping_Rule_Threshold', HPReduce_Stopping_Rule_Threshold,'G');
call symputx('segmentation_variables_needed',segmentation_variables_needed,'G');
call symputx('where_clause',where_clause,'G'); /* Where clause from segmentation variables */
call symputx("targetVar&targCnt",dependent_variable,'G');
call symputx("repeat",repeat,'G');
call symputx("Training_samppct",Training_samppct,'G');
call symputx("Event",Event,'G');
call symputx("HPLogistic_method_1",HPLogistic_method_1,'G'); /* Parameters for HPLOGISTIC 1 */
call symputx("HPLogistic_method_2",HPLogistic_method_2,'G'); /* Parameters for HPLOGISTIC 2 */
call symputx("HPNeural_method_1",HPNeural_method_1,'G'); /* Parameters for HPNEURAL 1*/
call symputx("HPNeural_method_2",HPNeural_method_2,'G'); /* Parameters for HPNEURAL 2*/
call symputx("HPForest_method_1",HPForest_method_1,'G'); /* Parameters for HPFOREST 1*/
call symputx("HPForest_method_2",HPForest_method_2,'G'); /* Parameters for HPFOREST 1*/
call symputx("HPREG_method_1",HPREG_method_1,'G'); /* Parameters for HPREG 1*/
call symputx("HPREG_method_2",HPREG_method_2,'G'); /* Parameters for HPREG 1*/
drop i;
run;
%put WHERE clause is: &where_clause.;
%** Parsing for HPNEURAL parameters ;
%do i=1 %to 2;
%let architecture_&i.= %scan(%scan(&&HPNeural_method_&i.,1,'|'),2,'=');
%let hidden_&i.= %scan(%scan(&&HPNeural_method_&i.,2,'|'),2,'=');
%let numtries_&i.= %scan(%scan(&&HPNeural_method_&i.,3,'|'),2,'=');
%let maxiter_&i.= %scan(%scan(&&HPNeural_method_&i.,4,'|'),2,'=');
%let weight_&i.= %scan(%scan(&&HPNeural_method_&i.,5,'|'),2,'=');
%put arch: &&architecture_&i.;
%put hidden: &&hidden_&i. ;
%put numtries: &&numtries_&i.;
%put maxiter: &&maxiter_&i.;
%put weight: &&weight_&i. ;
%end;
%** Delete existing SAS datasets that need to be used in this Model Factory run ;
%delete_sasdata_iff (perm.vcp_unsup_targ&targCnt)
%delete_sasdata_iff (perm.vcp_sup_targ&targCnt.)
;
%** Classify target variable as binary, continuous, categorical, or ordinal ;
proc sql;
SELECT COUNT(DISTINCT &&targetVar&targCnt) into :targ_freq FROM gplib.&dep_table.;
SELECT type into :targ_type FROM _contents_dep_table where upcase(name) = upcase("&&targetVar&targCnt");
quit;
OPTIONS NOMLOGIC NOSYMBOLGEN;
%** For the Target variable, Determine its frequency, type, and class for use in modeling ;
%put Frequency of Target variable &&targetVar&targCnt is &targ_freq.;
%put Type of Target variable &&targetVar&targCnt is &targ_type.;
%if (&targ_freq. = 2 and &targ_type. = 1) %then %do;
%let targ_class = binary numeric;
%let model_selection = _VMISC_;
%end;
%else %if (&targ_freq. = 2 and &targ_type. = 2) %then %do;
%let targ_class = binary categorical;
%let model_selection = _VMISC_;
%end;
%else %if (&targ_freq. > 2 and &targ_freq. < 10 and &targ_type. = 1) %then %DO;
%let targ_class = ordinal;
%let model_selection = _VMISC_;
%end;
%else %if (&targ_freq. >= 10 and &targ_type. = 1) %then %DO;
%let targ_class =interval;
%let model_selection = _VASE_;
%end;
%else %if (&targ_freq. > 2 and &targ_type. =2) %then %DO;
%let targ_class = categorical;
%let model_selection = _VMISC_;
%end;
%put Class of Target variable &&targetVar&targCnt is &targ_class.;
%** For each target variable, loop through the tables of independent variables. ;
%** Process each table, reducing each set of independent variables. ;
%** Both supervised and unsupervised variable reduction will be used ;
%** BEGIN: PROCESS EACH INDEPENDENT TABLE ;
%do tabCnt = 1 %to &tableCounter;
%** Create a new subset of independents using a two-step process, IF the where-clause ;
%** has changed so that the selected records will change: ;
%** - select just the records required by the new WHERE clause ;
%** - test the CSS for independents in that subset, removing any that have bad ;
%** CSS values within the subset. ;
%** "Remove" in this sense does not change the data. Rather, it changes a macro ;
%** variable holding a list of independents that will be processed further. ;
%if &repeat. = N %then %do;
%drop_table_iff(&&subtable&tabCnt)
%drop_table_iff(&&subschema&tabCnt)
proc sql;
Connect to Greenplm (server=&server user=&user password=&pwd
database=&database schema="&sschema" );
execute (set gp_autostats_mode='NONE') by Greenplm;
execute ( create table &&subschema&tabCnt with (appendonly=true, compresstype=QUICKLZ, OIDS=FALSE) as
select a.* from &&schema&tabCnt as a
&where_clause. DISTRIBUTED BY (&idVar.))by greenplm;
execute (analyze &&schema&tabCnt (&idVar.)) by Greenplm;
quit;
%** Test CSS for this subset. ;
%** TEMPORARY PITFALL: There is only one LIBNAME statement, which is used as part ;
%** of the SUBTABLE macro variables. However, the code above writes to the user ;
%** schema, which is used as part of the SUBSCHEMA macro variables. And both ;
%** locations refer to the same schema. So it is correct to switch from referring ;
%** to SUBSCHEMA to SUBTABLE as the HPDMDB input data. ;
proc hpdmdb data=&&subtable&tabCnt varout=summary_stats (keep=name css);
var &&numeric_indeps_kept_&tabCnt.;
&PERFORMANCE_STATEMENT. ;
run;
%local numeric_indeps_final_list_&tabCnt.;
proc sql noprint;
select strip(name) into : numeric_indeps_final_list_&tabCnt. separated by ' '
from summary_stats where (0 < css < 1.0e+30);
quit;
%end;
%** Supervised variable reduction ;
%** Investigating the relationship of each independent variable with the target ;
%** variable Using correlation between the two ;
%** The top 1550 variables from all the Supervised reduction will be used ;
title "Analysis row &tabCnt of &tableCounter, dependent is &&targetVar&targCnt";
title3 "Now processing &&subtable&tabCnt ...";
proc hpreduce data=&&subtable&tabCnt outcp=perm.cp_sup_table&tabCnt._targ&targCnt;
&PERFORMANCE_STATEMENT. ;
reduce supervised &&targetVar&targCnt = &&numeric_indeps_final_list_&tabCnt.. /
varexp = &varExpRedVal;
ods table selectionsummary=perm.sel_sup_table&tabCnt._targ&targCnt;
run;
data vcp_sup_table&tabCnt._targ&targCnt;
length table $32;
set perm.cp_sup_table&tabCnt._targ&targCnt;
where _type_ = 'CORR' and upcase(_var_) ^= upcase("&&targetVar&targCnt");
keep table_num table _var_ v1 vv1;
vv1 = abs(v1);
table = "&&table&tabCnt";
table_num = &tabCnt;
run;
%** Sort the results by descending correlation for each independent variable with the target variable ;
proc sort data=vcp_sup_table&tabCnt._targ&targCnt;
by descending vv1;
run;
proc sql;
create table vcp_sel_sup_table&tabCnt._targ&targCnt as select 'S' as Super, a.*,b.*
from perm.sel_sup_table&tabCnt._targ&targCnt a
left join vcp_sup_table&tabCnt._targ&targCnt b
on variable = _var_ order by VarExp;
quit;
options &original_settings;
%** The reduce_summary macro produces a report of the variable reduction and creates needed macro variables ;
%reduce_summary(perm.sel_sup_table&tabCnt._targ&targCnt)
%let n_reduce_vars_tab&tabCnt._targ&targCnt = &n_reduce_vars;
%let reduce_vars_tab&tabCnt._targ&targCnt = &reduce_vars;
%let reduce_vars_comma_tab&tabCnt._targ&targCnt = &reduce_vars_comma;
%let n_reduce_class_tab&tabCnt._targ&targCnt = &n_reduce_class;
%let reduce_class_tab&tabCnt._targ&targCnt = &reduce_class;
%let reduce_class_comma_tab&tabCnt._targ&targCnt = &reduce_class_comma;
%put NOTE: REDUCE VARS&tabcnt.: perm.sel_sup_table&tabCnt._targ&targCnt PRODUCES
&&n_reduce_vars_tab&tabCnt._targ&targCnt :
&&reduce_vars_tab&tabCnt._targ&targCnt &&reduce_vars_comma_tab&tabCnt._targ&targCnt ;
%put NOTE: REDUCE perm.sel_sup_table&tabCnt._targ&targCnt PRODUCES
&&n_reduce_class_tab&tabCnt._targ&targCnt :
&&reduce_class_tab&tabCnt._targ&targCnt &&reduce_class_comma_tab&tabCnt._targ&targCnt;
%** Unsupervised variable reduction ;
%** Investigating the relationship of each independent variable with respect to the ;
%** Total Variance Using correlation ;
%** The variables from the Unsupervised reduction will be used for interactions only ;
options MPRINT;
proc hpreduce data=&&subtable&tabCnt outcp=perm.cp_unsup_table&tabCnt._targ&targCnt;
&PERFORMANCE_STATEMENT. ;
reduce unsupervised &&numeric_indeps_final_list_&tabCnt.. /
varexp = &unSupVarExpRedVal;* maxeffects=300;
ods table selectionsummary=perm.sel_unsup_table&tabCnt._targ&targCnt;
run;
data perm.sel_unsup_table&tabCnt._targ&targCnt;
length table $32;
set perm.sel_unsup_table&tabCnt._targ&targCnt;
alag = lag(varexp); drop alag;
if varexp > 1 or varexp = . then varexp = alag;
Ivarexp = varexp - lag(varexp);
if _n_ = 1 then Ivarexp = varexp;
table = "&&table&tabCnt";
table_num = &tabCnt;
run;
%** Identify all independent variables in unsupervised not in supervised ;
%** The only independent variables from unsupervised that are of interest are those ;
%** from the not in the supervised list ;
proc sql;
create table sel_unsup_notsup&tabCnt._targ&targCnt as select 'U' as Super, a.*
from perm.sel_unsup_table&tabCnt._targ&targCnt a
where variable not in (select variable from vcp_sel_sup_table&tabCnt._targ&targCnt)
order by varexp;
quit;
%** END: PROCESS EACH INDEPENDENT TABLE ;
options &original_settings;
%end; /* End of processing each independent table */
%** Put all tables of unsupervised together ;
data perm.vcp_unsup_targ&targCnt;
LENGTH variable $ 32;
rename variable = _var_;
set %do tabCnt = 1 %to &tableCounter;
sel_unsup_notsup&tabCnt._targ&targCnt
%end;
;
run;
%** Put all tables of supervised together ;
data perm.vcp_sup_targ&targCnt;
LENGTH _var_ $ 32;
set %do tabCnt = 1 %to &tableCounter;
vcp_sup_table&tabCnt._targ&targCnt
%end;
;
run;
%** Sort the combined unsupervised results by variable name and then descending variance explained ;
%** Removing the duplicate names ;
proc sort data=perm.vcp_unsup_targ&targCnt;
by _var_ descending Ivarexp; /* variance explained */
run;
data perm.vcp_unsup_targ&targCnt; set perm.vcp_unsup_targ&targCnt;
by _var_; /* variable */
if first._var_;
run;
%** Sort the resulting combined unsupervised results by descending variance explained ;
proc sort data=perm.vcp_unsup_targ&targCnt;
by descending Ivarexp; /* variance explained */
run;
%** Sort the combined supervised results by variable name and then descending correlation ;
%** Removing the duplicate names ;
proc sort data=perm.vcp_sup_targ&targCnt;
by _var_ descending vv1; /* correlation */
run;
data perm.vcp_sup_targ&targCnt; set perm.vcp_sup_targ&targCnt;
by _var_; /* variable */
if first._var_;
run;
%** Sort the combined supervised results by descending correlation ;
proc sort data=perm.vcp_sup_targ&targCnt;
by descending vv1; /* correlation */
run;
%** Supervised: Take top 1,550 variables ;
data perm.svcp_sup_targ&targCnt;
set perm.vcp_sup_targ&targCnt (obs=1550);
run;
%** Supervised: Take top 20 variables ;
data perm.svcp_sup_targ_20_&targCnt;
set perm.vcp_sup_targ&targCnt (obs=20);
run;
%** Unsupervised: Take top 20 variables ;
data perm.svcp_unsup_targ&targCnt;
set perm.vcp_unsup_targ&targCnt (obs=20);
run;
%** Top 1,550 supervised, plus top 20 unsupervised ;
data perm.svcp_unsup_sup_targ&targCnt;
set perm.svcp_sup_targ&targCnt perm.svcp_unsup_targ&targCnt;
keep tab_var _var_ table table_num v1 vv1 varexp ivarexp;
tab_var = 'a' !! strip(table_num) !! '.' !! _var_;
run;
proc sort data=perm.svcp_unsup_sup_targ&targCnt nodupkey;
by _var_; /* alphabetic */
run;
proc sort data=perm.svcp_unsup_sup_targ&targCnt;
by descending vv1; /* correlation */
run;
%** Create list of variables for SQL and HPREDUCE ;
proc sql;
select tab_var into :tab_var_name separated by ',' from perm.svcp_unsup_sup_targ&targCnt;
select _var_ into :var_name separated by ',' from perm.svcp_unsup_sup_targ&targCnt;
select _var_ into :hpvar_name separated by ' ' from perm.svcp_unsup_sup_targ&targCnt;
select count(*) into :count from perm.svcp_unsup_sup_targ&targCnt;
%** Interaction terms: unsupervised * supervised, and unsupervised * unsupervised ;
select _var_ into :sup_var_name separated by ' ' from perm.svcp_sup_targ_20_&targCnt;
select _var_ into :unsup_var_name separated by ' ' from perm.svcp_unsup_targ&targCnt;
quit;
%put tab_var_name: &tab_var_name.;
%put var_name: &var_name.;
%put hpvar_name: &hpvar_name.;
%put count: &count.;
%put sup_var_name: &sup_var_name.;
%put unsup_var_name: &unsup_var_name.;
%** Create pairs of variables that will form interaction terms. ;
%** To guard against duplicates, NAME1 will be alphabetically closer to "A" than NAME2 ;
%** and NAME2 will be alphabetically closer to "Z" than NAME1. ;
%** The variable names for NAME1 and NAME2 will be derived from the names of the top 20 ;
%** supervised and the top 20 unsupervised variables ;
data pairs (keep=name1 name2);
length name1 name2 $ 32;
%** Take pairs involving top 20 UNsupervised vs. top 20 supervised. ;
length unsup_varname sup_varname $ 32;
do i = 1 to 20;
unsup_varname = upcase(scan("&unsup_var_name.",i));
if (unsup_varname > ' ') then do j = 1 to 20;
sup_varname = upcase(scan("&sup_var_name.",j));
if sup_varname < unsup_varname then do;
name1 = sup_varname;
name2 = unsup_varname;
output;
end;
else if unsup_varname < sup_varname then do;
name1 = unsup_varname;
name2 = sup_varname;
output;
end;
%** Automatically skips cases where sup_varname = unsup_varname. ;
end;
end;
%** Take pairs involving top 20 UNsupervised vs. top 20 UNsupervised. ;
length unsup_varname1 unsup_varname2 $ 32;
do i = 1 to 19;
unsup_varname1 = upcase(scan("&unsup_var_name.",i));
if (unsup_varname1 > ' ') then do j = i+1 to 20;
unsup_varname2 = upcase(scan("&unsup_var_name.",j));
if unsup_varname2 > ' ' then do;
if unsup_varname1 < unsup_varname2 then do;
name1 = unsup_varname1;
name2 = unsup_varname2;
output;
end;
else do;
name1 = unsup_varname2;
name2 = unsup_varname1;
output;
end;
end;
end;
end;
run;
proc sort data=pairs NODUPKEY;
by name1 name2;
run;
%local interactions1 interactions2;
%let interactions1=;
%let interactions2=;
%** Put the interaction terms into macro variables called interactions1 and interactions2 ;
data _null_;
length string1 string2 $ 30000;
retain string1 string2;
set pairs end=done;
if length(string1) < 29030 then
string1 = strip(string1) || ' ' || strip(name1) || '*' || strip(name2);
else
string2 = strip(string2) || ' ' || strip(name1) || '*' || strip(name2);
if done;
call symputx('interactions1', string1);
call symputx('interactions2', string2);
run;
%put INTERACTIONS SET #1: &interactions1;
%put INTERACTIONS SET #2: &interactions2;
%let lt1tableCounter = %eval(&tableCounter - 1);
%** Create greenplum table of supervised and unsupervised variables needed for analysis ;
%** If there are more than 20 tables of independent variables, then two steps will be required ;
%** to combine the 1550 supervised and 20 unsupervised variables together ;
options dsnferr;
%** Remove previously defined greenplum tables of supervised and unsupervised variables needed for analysis ;
%drop_table_iff (gplib.ALLdri_targ&targCnt._new)
%drop_table_iff (&sschema..ALLdri_targ&targCnt._new);
%** Less than or equal to 20 tables to join together ;
%if (&tableCounter <= 20) %then %do;
proc sql;
connect to Greenplm (server=&server user=&user password=&pwd
database=&database schema="&sschema" );
execute (set gp_autostats_mode='NONE') by Greenplm;
execute ( create table &sschema..ALLdri_targ&targCnt._new
with (appendonly=true, compresstype=QUICKLZ, OIDS=FALSE) as
select a1.&idVar., a1.&&targetVar&targCnt, &tab_var_name.
from
%do tabCnt = 1 %to <1tableCounter;
&&subschema&tabCnt. a&tabCnt.,
%end;
&&subschema&tableCounter. a&tableCounter.
where
%do tabCnt = 2 %to <1tableCounter;
a1.&idVar. = a&tabCnt..&idVar. and
%end;
a1.&idVar. = a&tableCounter..&idVar. DISTRIBUTED BY (&idVar.)) by greenplm
;
execute (analyze &sschema..ALLdri_targ&targCnt._new (&idVar.)) by Greenplm;
quit;
%end;
%** Greater than 20 tables to join together ;
%else %do;
%** Create 10 empty macro variables to hold the 10 lists of variables in the first join ;
%do i = 1 %to 10;
%let gvar&i = ;
%let tab_gvar&i = ;
%end;
%** Prepare for first joining by creating the list of variables to be put in each GP table ;
proc sql;
%let num_group = %eval((&tableCounter-1)/20 + 1);
%put &num_group;
%do i = 1 %to &num_group.;
%let strt = %eval((&i-1)*20+1);
%let stop = %eval(&i*20);
select _var_ into :gvar&i separated by ',' from perm.svcp_unsup_sup_targ&targCnt
where table_num>=&strt. and table_num<=&stop.;
%put &i &strt &stop &&gvar&i;
select tab_var into :tab_gvar&i separated by ',' from perm.svcp_unsup_sup_targ&targCnt
where table_num>=&strt. and table_num<=&stop.;
%put &i &strt &stop &&tab_gvar&i;
%end;
quit;
%** Perform joining of tables in groups of 20 or less up to 200 total tables ;
%do i = 1 %to &num_group.;
%let strt = %eval((&i-1)*20+1);
%let strt1 = %eval((&i-1)*20+2);
%let stop = %eval(&i*20-1);
%let last = %eval(&i*20);
%if (&i. = &num_group.) %then %do;
%let stop = %eval(&tableCounter-1);
%let last = &tableCounter;
%end;
proc sql;
connect to Greenplm (server=&server user=&user password=&pwd
database=&database schema="&sschema" );
execute (set gp_autostats_mode='NONE') by Greenplm;
execute ( create table &sschema..ALLdri_targ&targCnt._new&i.
with (appendonly=true, compresstype=QUICKLZ, OIDS=FALSE) as
%if &&gvar&i. = %then %do;
select a&strt..&idVar., a&strt..&&targetVar&targCnt
%end;
%else %do;
select a&strt..&idVar., a&strt..&&targetVar&targCnt, &&tab_gvar&i.
%end;
from
%do tabCnt = &strt. %to &stop.;
&&subschema&tabCnt. a&tabCnt.,
%end;
&&subschema&last. a&last.
where
%do tabCnt = &strt1. %to &stop.;
a&strt..&idVar. = a&tabCnt..&idVar. and
%end;
a&strt..&idVar. = a&last..&idVar. DISTRIBUTED BY (&idVar.)) by greenplm
;
execute (analyze &sschema..ALLdri_targ&targCnt._new&i. (&idVar.)) by Greenplm;
quit;
%end;
%** Perform joining of the up to 20 subtables into the final GP table for analysis ;
%let num_group1 = %eval(&num_group.-1);
proc sql;
connect to Greenplm (server=&server user=&user password=&pwd
database=&database schema="&sschema" );
execute (set gp_autostats_mode='NONE') by Greenplm;
execute ( create table &sschema..ALLdri_targ&targCnt._new
with (appendonly=true, compresstype=QUICKLZ, OIDS=FALSE) as
select a1.&idVar., a1.&&targetVar&targCnt, &var_name.
from
%do i = 1 %to &num_group1.;
&sschema..ALLdri_targ&targCnt._new&i. a&i.,
%end;
&sschema..ALLdri_targ&targCnt._new&num_group. a&num_group.
where
%do i = 2 %to &num_group1.;
a1.&idVar. = a&i..&idVar. and
%end;
a1.&idVar. = a&num_group..&idVar. DISTRIBUTED BY (&idVar.)) by greenplm
;
execute (analyze &sschema..ALLdri_targ&targCnt._new (&idVar.)) by Greenplm;
quit;
%** Delete temporary GP tables used above ;
%do i = 1 %to &num_group.;
%drop_table_iff (gplib.ALLdri_targ&targCnt._new&i.)
%drop_table_iff (&sschema..ALLdri_targ&targCnt._new&i.);
%end;
%end;
%** After each table of independent variables has been examined and the final 1550 supervised ;
%** and top interactions from all tables have been found, ;
%** A final HPREDUCE is run to determine the top variables and interactions that will be passed to ;
%** the modeling steps.A final HPREDUCE is run to determine the top variables and interactions that will be passed to ;
%** Perform supervised variable reduction (like varselect). ;
%** This step uses the top 1550 main efffects from all the tables, plus ;
%** the interactions from the top 20 from each of the supervised and unsupervised steps. ;
%** The interactions are the unsupervised by unsupervised, and unsupervised by supervised. ;
proc hpreduce data=gplib.ALLdri_targ&targCnt._new outcp=perm.cp_sup_targ&targCnt;
&PERFORMANCE_STATEMENT. ;
*class &&targetVar&targCnt / missing;
reduce supervised &&targetVar&targCnt = &hpvar_name &interactions1 &interactions2 /
%if %upcase(&HP_Reduce_Stopping_Rule.) = MINVARIANCEINCREMENT %then %do;
&HP_Reduce_Stopping_Rule. = &HPReduce_Stopping_Rule_Threshold.;
%end;
%else %do;
&HP_Reduce_Stopping_Rule. = &HPReduce_Stopping_Rule_Threshold.
MINVARIANCEINCREMENT = .0001; * hard coded;
%end;
ods table selectionsummary=perm.sel_sup_targ&targCnt;
run;
%** Include a maximum of 75 effects. ;
data perm.max_sel_sup_targ&targCnt;
set perm.sel_sup_targ&targCnt(obs=75);
run;
%** Separate interaction effects, drop * between variables ;
data perm.vsel_sup_targ&targCnt._only;
set perm.max_sel_sup_targ&targCnt;
length variable_a $32;
variable_a = 'wwwww';
rename variable_a=variable;
drop variable;
if scan(variable,2,'*') = ' ' then do;
variable_a=variable;
output;
end;
else do;
variable_a=scan(variable,1,'*'); output;
variable_a=scan(variable,2,'*'); output;
end;
run;
%** Create macro variable of top variables from hpreduce - NO interactions terms, but using all ;
%** variables including those from the interactions terms ;
proc sort data= perm.vsel_sup_targ&targCnt._only nodupkey;
by variable;
run;
proc sql;
select variable into :pred_var_name_only separated by ' '
from perm.vsel_sup_targ&targCnt._only
;
quit;
%** Create macro variable of top variables from hpreduce ;
proc sql;
select variable into :pred_var_name separated by ' ' from perm.max_sel_sup_targ&targCnt;
quit;
%put pred_var_name: &pred_var_name.;
%put pred_var_name_only: &pred_var_name_only.;
%** Creating partition using HPSAMPLE based on Training_samppct given in Parameter Table ;
%drop_table_iff (gplib.Part_ALLdri_targ&targCnt.)
proc hpsample data=gplib.ALLdri_targ&targCnt._new (keep = &idVar &&targetVar&targCnt &pred_var_name_only)
out=gplib.Part_ALLdri_targ&targCnt.
partition
samppct=&Training_samppct
seed=76576587;
&PERFORMANCE_STATEMENT. ;
class &idVar
%if %upcase(%scan(&targ_class.,1)) = BINARY %then %do;
&&targetVar&targCnt
%end;
;
%if %upcase(%scan(&targ_class.,1)) = BINARY %then %do;
target &&targetVar&targCnt;
%end;
var %if %upcase(%scan(&targ_class.,1)) ^= BINARY %then %do;
&&targetVar&targCnt
%end;
&pred_var_name_only.;
run;
%** Models created are based on target variable type. ;
%** Binary Numeric - HPLOGISTIC HPFOREST HPNEURAL ;
%** Binary Categorical - HPLOGISTIC HPFOREST HPNEURAL ;
%** Ordinal - HPLOGISTIC HPNEURAL ;
%** Interval - HPREG HPFOREST HPNEURAL ;
%** Categorical - HPLOGISTIC(LINK=GLOGIT) HPFOREST HPNEURAL ;
%** Depending on the class of the target variable, create needed macro variables to use in the ;
%** modeling algorithms ;
%if &targ_class =binary numeric %then %do;
%let DO_HP_LOGISTIC = Y;
%let DO_RESPONSE_OPTION= (DESC);
%let DO_LINK= ;
%let DO_ASSO= /ASSOCIATION;
%let DO_HP_NEURAL = Y;
%let DO_TARG_LEVEL= NOM;
%let DO_HP_FOREST = Y;
%let DO_HP_REG = N;
%let DO_LEVEL= BINARY;
%let c_stat=Y;
%let DO_TYPE=CLASSIFICATION;
%end;
%else %if &targ_class =binary categorical %then %do;
%let DO_HP_LOGISTIC = Y;
%let DO_RESPONSE_OPTION= (DESC);
%let DO_LINK= ;
%let DO_ASSO= /ASSOCIATION;
%let DO_HP_NEURAL = Y;
%let DO_TARG_LEVEL= NOM;
%let DO_HP_FOREST = Y;
%let DO_HP_REG = N;
%let DO_LEVEL= BINARY;
%let c_stat=Y;
%let DO_TYPE=CLASSIFICATION;
%end;
%else %if &targ_class =ordinal %then %do;
%let DO_HP_LOGISTIC = Y;
%let DO_RESPONSE_OPTION= ;
%let DO_LINK= ;
%let DO_ASSO= ;
%let DO_HP_NEURAL = Y;
%let DO_TARG_LEVEL= NOM;
%let DO_HP_FOREST = N;
%let DO_HP_REG = N;
%let DO_LEVEL= ORDINAL;
%let EVENT =;
%let c_stat=N;
%let DO_TYPE=CLASSIFICATION;
%end;
%else %if &targ_class =interval %then %do;
%let DO_HP_LOGISTIC = N;
%let DO_RESPONSE_OPTION= ;
%let DO_LINK= ;
%let DO_ASSO= ;
%let DO_HP_NEURAL = Y;
%let DO_TARG_LEVEL= INT;
%let DO_HP_FOREST = Y;
%let DO_HP_REG = Y;
%let DO_LEVEL= INTERVAL;
%let EVENT =;
%let c_stat=N;
%let DO_TYPE=PREDICTION;
%end;
%else %if &targ_class =categorical %then %do;
%let DO_HP_LOGISTIC = Y;
%let DO_RESPONSE_OPTION= ;
%let DO_LINK= /LINK=GLOGIT;
%let DO_ASSO= ;
%let DO_HP_NEURAL = Y;
%let DO_TARG_LEVEL= NOM;
%let DO_HP_FOREST = Y;
%let DO_HP_REG = N;
%let DO_LEVEL= NOMINAL;
%let EVENT =;
%let c_stat=N;
%let DO_TYPE=CLASSIFICATION;
%end;
%** There are 4 Model Types depending on the class of the target variable ;
%** #1: PROC HPLOGISTIC ;
%** #2: PROC HP_NEURAL ;
%** #3: PROC HP_FOREST ;
%** #4: PROC HP_REG ;
%** Model Type #1: PROC HPLOGISTIC ;
%** _PARTIND_ =1 corresponds to TRAINING, _PARTIND_=0 corresponds to VALIDATION ;
%** Estimate logistic regression on the TRAINING sample ;
%if &DO_HP_LOGISTIC.= Y %then %do;
%local k;
%let HPLogistic_used_1 = N;
%let HPLogistic_used_2 = N;
%do k= 1 %to 2; * Start of HPLOGISTIC iterations;
%** Check whether HPLOGISTIC_method parameter is blank ;
%if "&&HPLogistic_method_&k." ^= "" %then %do;
%let HPLogistic_used_&k. = Y;
title "PROC HPLOGISTIC for &&targetVar&targCnt. (&targ_class. dependent variable) using Selection method= &&HPLogistic_method_&k.";
proc hplogistic data=gplib.Part_ALLdri_targ&targCnt. (where = (_PARTIND_ = 1))
noclprint noitprint nostderr ;
&PERFORMANCE_STATEMENT. ;
id &idVar;
class &idVar &&targetVar&targCnt.;
selection method=&&HPLogistic_method_&k.;
model &&targetVar&targCnt. &DO_RESPONSE_OPTION. = &pred_var_name. &do_link. &DO_ASSO. ;
ods output parameterestimates=perm.est_HPLog_&k._targ&targCnt.
modelinfo=info_HPLog_&k._targ&targCnt.
%if "&DO_ASSO." ^= "" %then %do;
association=Asso&k._targ&targCnt.
%end;
;
output pred=pred_HPLog_&k._targ&targCnt.;
code file = "&rootPath/HL_&k._targ&targCnt..sas";
run;
title;
%** DS TRANS code can run on GP ;
filename _outds2 "DS2_HL_&k._targ&targCnt..sas";
proc dstrans ds_to_ds2
in = "&rootPath/HL_&k._targ&targCnt..sas"
out = _outds2
outdir = "&rootPath/"
aster
nocomp;
run;
quit;
filename _outds2;
%drop_table_iff (gplib.HL_&k._scores_targ&targCnt.)
%** Score Training and Validation samples using hplogistic ;
proc hpds2 data=gplib.Part_ALLdri_targ&targCnt.
out=gplib.HL_&k._scores_targ&targCnt.;
%include "&rootPath/DS2_HL_&k._targ&targCnt..sas";
&PERFORMANCE_STATEMENT. ;
run;
%** Produce plots and tables of scored data ;
%delete_sasdata_iff (perm.bins_HLog_&k._targ&targCnt.)
%delete_sasdata_iff (perm.binstat_HLog_&k._targ&targCnt.)
%delete_sasdata_iff (perm.expand_HLog_&k._targ&targCnt.)
%aamodel
%aa_model_eval (DATA = gplib.HL_&k._scores_targ&targCnt.,
TARGET = &&targetVar&targCnt.,
VAR = p_&&targetVar&targCnt..&Event.,
LEVEL = &DO_LEVEL.,
EVENT= &Event.,
OUT = perm.bins_HLog_&k._targ&targCnt.,
BINSTATS=perm.binstat_HLog_&k._targ&targCnt.,
BINS = 20,
HPDS2 = Y,
EXPAND= perm.expand_HLog_&k._targ&targCnt. ,
partitionvar=_partind_)
%em_new_report_JW (bins=perm.bins_HLog_&k._targ&targCnt.,
binstats=perm.binstat_HLog_&k._targ&targCnt.,
expand=perm.expand_HLog_&k._targ&targCnt.)
%end;
%end;
%end;
%** Model Type #2: HP NEURAL ;
%if &DO_HP_NEURAL.=Y %then %do;