-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLoan Prediction - SAS Studio.sas
1768 lines (1385 loc) · 59.2 KB
/
Loan Prediction - SAS Studio.sas
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
/*********************************************************************************************
Name of DS: Mr.Mario Caesar Kristantoputra-(TP061966)
Name of SAS program: mydapassignment_TP061966.sas
Description: SAS Codes for Data Analytical Programming in Lasiandra Finance Inc.
Data first written: Mon, 19-Jul-2021
Data last updated: Fri, 03-Sep-2021
Folder name: MYDAPFTTP061966
Library name: LIBFT966
**********************************************************************************************/
/*********************************************************************************************
To Create a Copy of "TRAINING_DS" Dataset
**********************************************************************************************/
TITLE 'Create a Copy of "TRAINING_DS" Dataset';
/* SAS code to create a copy of "TRAINING_DS" dataset */
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_DS_TP061966_BK AS
SELECT * FROM LIBFT966.TRAINING_DS;
QUIT;
/*********************************************************************************************
To Display the Structure (Metadata) of "TRAINING_DS_TP061966_BK" Dataset
**********************************************************************************************/
TITLE 'Display the Structure (Metadata) of "TRAINING_DS_TP061966_BK" Dataset';
/* SAS code to display the structure (metadata) of "TRAINING_DS" dataset */
PROC SQL;
DESCRIBE TABLE LIBFT966.TRAINING_DS_TP061966_BK;
QUIT;
/*********************************************************************************************
To Label Each Variable of the "TRAINING_DS_TP061966_BK" Dataset
**********************************************************************************************/
TITLE 'Label Each Variable of the Dataset';
/* SAS code to label each variable of the "TRAINING_DS_TP061966_BK" dataset */
DATA LIBFT966.TRAINING_DS_TP061966_BK;
SET LIBFT966.TRAINING_DS_TP061966_BK;
LABEL SME_LOAN_ID_NO = 'Loan Application Number'
GENDER = 'Gender Name'
MARITAL_STATUS = 'Marital Status'
FAMILY_MEMBERS = 'Family Members'
QUALIFICATION = 'Qualification'
EMPLOYMENT = 'Employment'
CANDIDATE_INCOME = 'Candidate Income'
GUARANTEE_INCOME = 'Guarantee Income'
LOAN_AMOUNT = 'Loan Amount'
LOAN_DURATION = 'Loan Duration'
LOAN_HISTORY = 'Loan History'
LOAN_LOCATION = 'Loan Location'
LOAN_APPROVAL_STATUS = 'Loan Approval Status';
RUN;
/*********************************************************************************************
To Display "TRAINING_DS_TP061966_BK" Dataset after labelling
**********************************************************************************************/
TITLE 'TRAINING_DS_TP061966_BK table after labelling';
/* SAS code to display table after labelling */
PROC SQL;
SELECT * FROM LIBFT966.TRAINING_DS_TP061966_BK;
RUN;
/*********************************************************************************************
Univariate Analysis
**********************************************************************************************/
/*********************************************************************************************
Categorical Variable
**********************************************************************************************/
/* GENDER */
TITLE 'Univariate Analysis of the "GENDER" Variable - Categorical Variable';
/* SAS code to do Univariate Analysis of the "GENDER" variable */
PROC FREQ DATA = LIBFT966.TRAINING_DS_TP061966_BK;
TABLE GENDER;
RUN;
ODS GRAPHICS / RESET WIDTH=4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBAR GENDER;
RUN;
/* MARITAL_STATUS */
TITLE 'Univariate Analysis of the "MARITAL_STATUS" Variable - Categorical Variable';
/* SAS code to do Univariate Analysis of the "MARITAL_STATUS" variable */
PROC FREQ DATA = LIBFT966.TRAINING_DS_TP061966_BK;
TABLE MARITAL_STATUS;
RUN;
ODS GRAPHICS / RESET WIDTH=4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBAR MARITAL_STATUS;
RUN;
/* FAMILY_MEMBERS */
TITLE 'Univariate Analysis of the "FAMILY_MEMBERS" Variable - Categorical Variable';
/* SAS code to do Univariate Analysis of the "FAMILY_MEMBERS" variable */
PROC FREQ DATA = LIBFT966.TRAINING_DS_TP061966_BK;
TABLE FAMILY_MEMBERS;
RUN;
ODS GRAPHICS / RESET WIDTH=4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBAR FAMILY_MEMBERS;
RUN;
/* QUALIFICATION */
TITLE 'Univariate Analysis of the "QUALIFICATION" Variable - Categorical Variable';
/* SAS code to do Univariate Analysis of the "QUALIFICATION" variable */
PROC FREQ DATA = LIBFT966.TRAINING_DS_TP061966_BK;
TABLE QUALIFICATION;
RUN;
ODS GRAPHICS / RESET WIDTH=4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBAR QUALIFICATION;
RUN;
/* EMPLOYMENT */
TITLE 'Univariate Analysis of the "EMPLOYMENT" Variable - Categorical Variable';
/* SAS code to do Univariate Analysis of the "EMPLOYMENT" variable */
PROC FREQ DATA = LIBFT966.TRAINING_DS_TP061966_BK;
TABLE EMPLOYMENT;
RUN;
ODS GRAPHICS / RESET WIDTH=4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBAR EMPLOYMENT;
RUN;
/* LOAN_HISTORY */
TITLE 'Univariate Analysis of the "LOAN_HISTORY" Variable - Categorical Variable';
/* SAS code to do Univariate Analysis of the "LOAN_HISTORY" variable */
PROC FREQ DATA = LIBFT966.TRAINING_DS_TP061966_BK;
TABLE LOAN_HISTORY;
RUN;
ODS GRAPHICS / RESET WIDTH=4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBAR LOAN_HISTORY;
RUN;
/* LOAN_LOCATION */
TITLE 'Univariate Analysis of the "LOAN_LOCATION" Variable - Categorical Variable';
/* SAS code to do Univariate Analysis of the "LOAN_LOCATION" variable */
PROC FREQ DATA = LIBFT966.TRAINING_DS_TP061966_BK;
TABLE LOAN_LOCATION;
RUN;
ODS GRAPHICS / RESET WIDTH=4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBAR LOAN_LOCATION;
RUN;
/* LOAN_APPROVAL_STATUS */
TITLE 'Univariate Analysis of the "LOAN_APPROVAL_STATUS" Variable - Categorical Variable';
/* SAS code to do Univariate Analysis of the "LOAN_APPROVAL_STATUS" variable */
PROC FREQ DATA = LIBFT966.TRAINING_DS_TP061966_BK;
TABLE LOAN_APPROVAL_STATUS;
RUN;
ODS GRAPHICS / RESET WIDTH=4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBAR LOAN_APPROVAL_STATUS;
RUN;
/*********************************************************************************************
Numerical Variable
**********************************************************************************************/
/* CANDIDATE_INCOME */
TITLE 'Univariate Analysis of the "CANDIDATE_INCOME" Variable - Continuous Variable';
/* SAS code to do Univariate Analysis of the "CANDIDATE_INCOME" variable */
PROC MEANS DATA = LIBFT966.TRAINING_DS_TP061966_BK N NMISS MIN MAX MEAN MEDIAN STD;
VAR CANDIDATE_INCOME;
RUN;
ODS GRAPHICS / RESET WIDTH =4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
HISTOGRAM CANDIDATE_INCOME;
RUN;
/* GUARANTEE_INCOME */
TITLE 'Univariate Analysis of the "GUARANTEE_INCOME" Variable - Continuous Variable';
/* SAS code to do Univariate Analysis of the "GUARANTEE_INCOME" variable */
PROC MEANS DATA = LIBFT966.TRAINING_DS_TP061966_BK N NMISS MIN MAX MEAN MEDIAN STD;
VAR GUARANTEE_INCOME;
RUN;
ODS GRAPHICS / RESET WIDTH =4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
HISTOGRAM GUARANTEE_INCOME;
RUN;
/* LOAN_AMOUNT */
TITLE 'Univariate Analysis of the "LOAN_AMOUNT" Variable - Continuous Variable';
/* SAS code to do Univariate Analysis of the "LOAN_AMOUNT" variable */
PROC MEANS DATA = LIBFT966.TRAINING_DS_TP061966_BK N NMISS MIN MAX MEAN MEDIAN STD;
VAR LOAN_AMOUNT;
RUN;
ODS GRAPHICS / RESET WIDTH =4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
HISTOGRAM LOAN_AMOUNT;
RUN;
/* LOAN_DURATION */
TITLE 'Univariate Analysis of the "LOAN_DURATION" Variable - Continuous Variable';
/* SAS code to do Univariate Analysis of the "LOAN_DURATION" variable */
PROC MEANS DATA = LIBFT966.TRAINING_DS_TP061966_BK N NMISS MIN MAX MEAN MEDIAN STD;
VAR LOAN_DURATION;
RUN;
ODS GRAPHICS / RESET WIDTH =4.0 IN HEIGHT=3.0 IN IMAGEMAP;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
HISTOGRAM LOAN_DURATION;
RUN;
/*********************************************************************************************
Bivariate Analysis on the dataset TRAINING_DS_TP061966_BK using Macro
**********************************************************************************************/
/*********************************************************************************************
To create a MACRO for bivariate analysis on categorical variable versus categorical variable
**********************************************************************************************/
%MACRO MACRO_BIVA_CV_TP061966( DATASET_NAME, VARIABLE_1, VARIABLE_2, TITLE_1, TITLE_2);
PROC FREQ DATA = &DATASET_NAME;
TABLE &VARIABLE_1 * &VARIABLE_2 /
PLOTS = FREQPLOT( TWOWAY = STACKED SCALE = GROUPPCT );
TITLE &TITLE_1;
TITLE2 &TITLE_2;
RUN;
%MEND MACRO_BIVA_CV_TP061966;
/*********************************************************************************************
To run bivariate analysis on Categorical variable versus Categorical variable
**********************************************************************************************/
/* GENDER Vs. MARITAL_STATUS */
%MACRO_BIVA_CV_TP061966(LIBFT966.TRAINING_DS_TP061966_BK, GENDER, MARITAL_STATUS, 'Bivariate analysis', 'on GENDER (Categorical) Vs. MARITAL_STATUS (Categorical)');
/* FAMILY_MEMBERS Vs. QUALIFICATION */
%MACRO_BIVA_CV_TP061966(LIBFT966.TRAINING_DS_TP061966_BK, FAMILY_MEMBERS, QUALIFICATION, 'Bivariate analysis', 'on FAMILY_MEMBERS (Categorical) Vs. QUALIFICATION (Categorical)');
/* EMPLOYMENT Vs. LOAN_HISTORY */
%MACRO_BIVA_CV_TP061966(LIBFT966.TRAINING_DS_TP061966_BK, EMPLOYMENT, LOAN_HISTORY, 'Bivariate analysis', 'on EMPLOYMENT (Categorical) Vs. LOAN_HISTORY (Categorical)');
/* LOAN_LOCATION Vs. LOAN_APPROVAL_STATUS */
%MACRO_BIVA_CV_TP061966(LIBFT966.TRAINING_DS_TP061966_BK, LOAN_LOCATION, LOAN_APPROVAL_STATUS, 'Bivariate analysis', 'on LOAN_LOCATION (Categorical) Vs. LOAN_APPROVAL_STATUS (Categorical)');
/* GENDER Vs. LOAN_APPROVAL_STATUS */
%MACRO_BIVA_CV_TP061966(LIBFT966.TRAINING_DS_TP061966_BK, GENDER, LOAN_APPROVAL_STATUS, 'Bivariate analysis', 'on GENDER (Categorical) Vs. LOAN_APPROVAL_STATUS (Categorical)');
/*********************************************************************************************
Categorical Vs. Numerical
**********************************************************************************************/
/* LOAN_APPROVAL_STATUS Vs. CANDIDATE_INCOME */
PROC MEANS DATA = LIBFT966.TRAINING_DS_TP061966_BK;
/* SAS code to do Bivariate Analysis of the "LOAN_APPROVAL_STATUS" vs. "CANDIDATE_INCOME" variable */
CLASS LOAN_APPROVAL_STATUS ; /* CHAR */
VAR CANDIDATE_INCOME; /* NUMERIC */
TITLE "Bivariate analysis on LOAN_APPROVAL_STATUS ( CHAR ) Versus CANDIDATE_INCOME ( NUMERIC )";
RUN;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBOX CANDIDATE_INCOME / CATEGORY = LOAN_APPROVAL_STATUS ;
TITLE "Bivariate analysis on LOAN_APPROVAL_STATUS ( CHAR ) Versus CANDIDATE_INCOME ( NUMERIC )";
RUN;
/* LOAN_APPROVAL_STATUS Vs. GUARANTEE_INCOME */
PROC MEANS DATA = LIBFT966.TRAINING_DS_TP061966_BK;
/* SAS code to do Bivariate Analysis of the "LOAN_APPROVAL_STATUS" vs. "GUARANTEE_INCOME" variable */
CLASS LOAN_APPROVAL_STATUS ; /* CHAR */
VAR GUARANTEE_INCOME; /* NUMERIC */
TITLE "Bivariate analysis on LOAN_APPROVAL_STATUS ( CHAR ) Versus GUARANTEE_INCOME ( NUMERIC )";
RUN;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBOX GUARANTEE_INCOME / CATEGORY = LOAN_APPROVAL_STATUS ;
TITLE "Bivariate analysis on LOAN_APPROVAL_STATUS ( CHAR ) Versus GUARANTEE_INCOME ( NUMERIC )";
RUN;
/* LOAN_APPROVAL_STATUS Vs. LOAN_AMOUNT */
PROC MEANS DATA = LIBFT966.TRAINING_DS_TP061966_BK;
/* SAS code to do Bivariate Analysis of the "LOAN_APPROVAL_STATUS" vs. "LOAN_AMOUNT" variable */
CLASS LOAN_APPROVAL_STATUS ; /* CHAR */
VAR LOAN_AMOUNT; /* NUMERIC */
TITLE "Bivariate analysis on LOAN_APPROVAL_STATUS ( CHAR ) Versus LOAN_AMOUNT ( NUMERIC )";
RUN;
PROC SGPLOT DATA = LIBFT966.TRAINING_DS_TP061966_BK;
VBOX LOAN_AMOUNT / CATEGORY = LOAN_APPROVAL_STATUS ;
TITLE "Bivariate analysis on LOAN_APPROVAL_STATUS ( CHAR ) Versus LOAN_AMOUNT ( NUMERIC )";
RUN;
/*********************************************************************************************
Numerical Vs. Numerical
**********************************************************************************************/
/* CANDIDATE_INCOME Vs. GUARANTEE_INCOME */
PROC CORR DATA = LIBFT966.TRAINING_DS_TP061966_BK PLOTS = SCATTER;
/* SAS code to do Bivariate Analysis of the "CANDIDATE_INCOME" vs. "GUARANTEE_INCOME" variable */
VAR CANDIDATE_INCOME GUARANTEE_INCOME;
ODS GRAPHICS / RESET WIDTH = 4.0 IN HEIGHT = 3.0 IN IMAGEMAP;
TITLE "Bivariate analysis on CANDIDATE_INCOME ( NUMERIC ) Versus GUARANTEE_INCOME ( NUMERIC )";
QUIT;
/* LOAN_AMOUNT Vs. LOAN_DURATION */
PROC CORR DATA = LIBFT966.TRAINING_DS_TP061966_BK PLOTS = SCATTER;
/* SAS code to do Bivariate Analysis of the "LOAN_AMOUNT" vs. "LOAN_DURATION" variable */
VAR LOAN_AMOUNT LOAN_DURATION;
ODS GRAPHICS / RESET WIDTH = 4.0 IN HEIGHT = 3.0 IN IMAGEMAP;
TITLE "Bivariate analysis on LOAN_AMOUNT ( NUMERIC ) Versus LOAN_DURATION ( NUMERIC )";
QUIT;
/************************************************************************
Imputation for categorical variable on dataset LIBFT966.TRAINING_TP061966
*************************************************************************/
/******************************
GENDER - Categorical Variable
*******************************/
/* Step 1. Make a copy of TRAINING_TP061966_COPY_DS */
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_GENDER_DS_BK AS
SELECT * FROM LIBFT966.TRAINING_DS_TP061966_BK;
QUIT;
/* Step 2. List the Missing Values in "GENDER" Variable */
TITLE 'Before Imputation: ';
TITLE2 'List the missing values';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK g
WHERE ( ( g.gender EQ '' ) OR
( g.gender IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "GENDER" Variable';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK g
WHERE ( ( g.gender EQ '' ) OR
( g.gender IS NULL) );
QUIT;
/* Step 3. Make a copy from current table to Count the Total Observations from Each GENDER */
TITLE 'Make a copy from current table to Count the Total Observations from Each GENDER';
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_GENDER_DS_BK_NEW AS
SELECT g.GENDER AS GENDER_NAME, COUNT(*) AS TOTAL_COUNTS
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK g
WHERE ( ( g.GENDER IS NOT NULL ) OR
( g.GENDER NE '' ) )
GROUP BY g.GENDER;
QUIT;
/* Step 4. Display the content in new table that has previously created */
TITLE 'Count of Total Observations from Each Gender';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK_NEW;
QUIT;
/* Step 5. Find the Maximum Count in new table */
TITLE 'Maximum Count in new table';
PROC SQL;
SELECT MAX(g.TOTAL_COUNTS) AS MAX_COUNTS
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK_NEW g;
QUIT;
/* Step 6. Find the mode for "GENDER" variable */
TITLE 'Mode for "GENDER" variable';
PROC SQL;
SELECT go.GENDER_NAME
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK_NEW go
WHERE go.TOTAL_COUNTS EQ ( SELECT MAX(gi.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK_NEW gi);
/* subquery to find the mode for gender */
QUIT;
/* Step 7. Impute the missing values using mode */
TITLE 'Impute the missing values using mode';
PROC SQL;
UPDATE LIBFT966.TRAINING_FI_GENDER_DS_BK
SET GENDER = ( SELECT go.GENDER_NAME
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK_NEW go
WHERE go.TOTAL_COUNTS EQ ( SELECT MAX(gi.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK_NEW gi ) )
WHERE ( ( GENDER IS NULL) OR
( GENDER EQ '' ) );
QUIT;
/* Step 8. List the Missing Values in "GENDER" Variable after imputation */
TITLE 'After Imputation: ';
TITLE2 'List the missing values after imputation';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK g
WHERE ( ( g.gender EQ '' ) OR
( g.gender IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "GENDER" Variable after imputation';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_GENDER_DS_BK g
WHERE ( ( g.gender EQ '' ) OR
( g.gender IS NULL) );
QUIT;
/******************************
FAMILY_MEMBERS - Categorical Variable
*******************************/
/* Step 1. Make a copy of LIBFT966.TRAINING_FI_GENDER_DS_BK */
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK AS
SELECT * FROM LIBFT966.TRAINING_FI_GENDER_DS_BK;
QUIT;
/* Step 2. List the Missing Values in "FAMILY_MEMBERS" Variable */
TITLE 'Before Imputation: ';
TITLE2 'List the missing values';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK fm
WHERE ( ( fm.FAMILY_MEMBERS EQ '' ) OR
( fm.FAMILY_MEMBERS IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "FAMILY_MEMBERS" Variable';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK FM
WHERE ( ( fm.FAMILY_MEMBERS EQ '' ) OR
( fm.FAMILY_MEMBERS IS NULL) );
QUIT;
/* Step 3. Make a copy from current table to Count the Total Observations from Each family members */
TITLE 'Make a copy from current table to Count the Total Observations from Each family members';
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_FM_DS_BK_N AS
SELECT fm.FAMILY_MEMBERS AS FAMILY_MEMBERS, COUNT(*) AS TOTAL_COUNTS
FROM LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK fm
WHERE ( ( fm.FAMILY_MEMBERS IS NOT NULL ) OR
( fm.FAMILY_MEMBERS NE '' ) )
GROUP BY fm.FAMILY_MEMBERS;
QUIT;
/* Step 4. Display the content in new table that has previously created */
TITLE 'Count of Total Observations from Each family members';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_FM_DS_BK_N;
QUIT;
/* Step 5. Find the Maximum Count in new table */
TITLE 'Maximum Count in new table';
PROC SQL;
SELECT MAX(fm.TOTAL_COUNTS) AS MAX_COUNTS
FROM LIBFT966.TRAINING_FI_FM_DS_BK_N fm;
QUIT;
/* Step 6. Find the mode for "FAMILY_MEMBERS" variable */
TITLE 'Mode for "FAMILY_MEMBERS" variable';
PROC SQL;
SELECT fmo.FAMILY_MEMBERS
FROM LIBFT966.TRAINING_FI_FM_DS_BK_N fmo
WHERE fmo.TOTAL_COUNTS EQ ( SELECT MAX(fmi.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_FM_DS_BK_N fmi);
/* subquery to find the mode for family members */
QUIT;
/* Step 7. Impute the missing values using mode */
TITLE 'Impute the missing values using mode';
PROC SQL;
UPDATE LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK
SET FAMILY_MEMBERS = ( SELECT fmo.FAMILY_MEMBERS
FROM LIBFT966.TRAINING_FI_FM_DS_BK_N fmo
WHERE fmo.TOTAL_COUNTS EQ ( SELECT MAX(fmi.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_FM_DS_BK_N fmi ) )
WHERE ( ( FAMILY_MEMBERS IS NULL) OR
( FAMILY_MEMBERS EQ '' ) );
QUIT;
/* Step 8. List the Missing Values in "FAMILY_MEMBERS" Variable after imputation */
TITLE 'After Imputation: ';
TITLE2 'List the missing values after imputation';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK fm
WHERE ( ( fm.FAMILY_MEMBERS EQ '' ) OR
( fm.FAMILY_MEMBERS IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "FAMILY_MEMBERS" Variable after imputation';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK fm
WHERE ( ( fm.FAMILY_MEMBERS EQ '' ) OR
( fm.FAMILY_MEMBERS IS NULL) );
QUIT;
/* SAS codes to remove '+" */
/* Step 1: SAS Code to List "3+" in FAMILY_MEMBERS variable */
TITLE 'List of "3+" in FAMILY_MEMBERS variable';
PROC SQL;
SELECT fm.FAMILY_MEMBERS,
SUBSTR(fm.FAMILY_MEMBERS,1,1),
SUBSTR(fm.FAMILY_MEMBERS,2,1)
FROM LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK fm
WHERE ( SUBSTR(fm.FAMILY_MEMBERS,2,1) EQ '+');
QUIT;
/* Step 2: Count Total Observations that has "+" in "FAMILY_MEMBERS" variable */
TITLE 'Total Observations that has "+" in "FAMILY_MEMBERS" variable';
PROC SQL;
SELECT COUNT(*) LABEL = 'Total Observation'
FROM LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK fm
WHERE ( SUBSTR(fm.FAMILY_MEMBERS,2,1) EQ '+' );
QUIT;
/* Step 3: Remove "+" from Observations in "FAMILY_MEMBERS" variable */
TITLE 'Remove "+" from Observations in "FAMILY_MEMBERS" variable';
PROC SQL;
UPDATE LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK
SET FAMILY_MEMBERS = SUBSTR(FAMILY_MEMBERS,1,1)
WHERE ( SUBSTR(FAMILY_MEMBERS,2,1) EQ '+' );
QUIT;
/* Step 4: List the Observations after removing "+" in "FAMILY_MEMBERS" variable */
TITLE 'List the Observations after removing "+" in "FAMILY_MEMBERS" variable';
PROC SQL;
SELECT fm.FAMILY_MEMBERS LABEL = 'FAMILY_MEMBERS',
COUNT(*) LABEL = 'Number of Applicants'
FROM LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK fm
GROUP BY fm.FAMILY_MEMBERS;
QUIT;
/******************************
MARITAL_STATUS - Categorical Variable
*******************************/
/* Step 1. Make a copy of LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK */
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_MARITAL_STATUS_DS_BK AS
SELECT * FROM LIBFT966.TRAINING_FI_FAMILY_MEMBERS_DS_BK;
QUIT;
/* Step 2. List the Missing Values in "MARITAL_STATUS" Variable */
TITLE 'Before Imputation: ';
TITLE2 'List the missing values';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_MARITAL_STATUS_DS_BK ms
WHERE ( ( ms.MARITAL_STATUS EQ '' ) OR
( ms.MARITAL_STATUS IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "MARITAL_STATUS" Variable';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_MARITAL_STATUS_DS_BK ms
WHERE ( ( ms.MARITAL_STATUS EQ '' ) OR
( ms.MARITAL_STATUS IS NULL) );
QUIT;
/* Step 3. Make a copy from current table to Count the Total Observations from Each marital status */
TITLE 'Make a copy from current table to Count the Total Observations from Each marital status';
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_MS_DS_BK_NEW AS
SELECT ms.MARITAL_STATUS AS MARITAL_STATUS, COUNT(*) AS TOTAL_COUNTS
FROM LIBFT966.TRAINING_FI_MARITAL_STATUS_DS_BK ms
WHERE ( ( ms.MARITAL_STATUS IS NOT NULL ) OR
( ms.MARITAL_STATUS NE '' ) )
GROUP BY ms.MARITAL_STATUS;
QUIT;
/* Step 4. Display the content in new table that has previously created */
TITLE 'Count of Total Observations from Each family members';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_MS_DS_BK_NEW;
QUIT;
/* Step 5. Find the Maximum Count in new table */
TITLE 'Maximum Count in new table';
PROC SQL;
SELECT MAX(ms.TOTAL_COUNTS) AS MAX_COUNTS
FROM LIBFT966.TRAINING_FI_MS_DS_BK_NEW ms;
QUIT;
/* Step 6. Find the mode for "MARITAL_STATUS" variable */
TITLE 'Mode for "MARITAL_STATUS" variable';
PROC SQL;
SELECT mso.MARITAL_STATUS
FROM LIBFT966.TRAINING_FI_MS_DS_BK_NEW mso
WHERE mso.TOTAL_COUNTS EQ ( SELECT MAX(msi.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_MS_DS_BK_NEW msi);
/* subquery to find the mode for marital status */
QUIT;
/* Step 7. Impute the missing values using mode */
TITLE 'Impute the missing values using mode';
PROC SQL;
UPDATE LIBFT966.TRAINING_FI_MARITAL_STATUS_DS_BK
SET MARITAL_STATUS = ( SELECT mso.MARITAL_STATUS
FROM LIBFT966.TRAINING_FI_MS_DS_BK_NEW mso
WHERE mso.TOTAL_COUNTS EQ ( SELECT MAX(msi.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_MS_DS_BK_NEW msi ) )
WHERE ( ( MARITAL_STATUS IS NULL) OR
( MARITAL_STATUS EQ '' ) );
QUIT;
/* Step 8. List the Missing Values in "MARITAL_STATUS" Variable after imputation */
TITLE 'After Imputation: ';
TITLE2 'List the missing values after imputation';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_MARITAL_STATUS_DS_BK ms
WHERE ( ( ms.MARITAL_STATUS EQ '' ) OR
( ms.MARITAL_STATUS IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "MARITAL_STATUS" Variable after imputation';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_MARITAL_STATUS_DS_BK ms
WHERE ( ( ms.MARITAL_STATUS EQ '' ) OR
( ms.MARITAL_STATUS IS NULL) );
QUIT;
/******************************
EMPLOYMENT - Categorical Variable
*******************************/
/* Step 1. Make a copy of LIBFT966.TRAINING_FI_MARITAL_STATUS_DS_BK */
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK AS
SELECT * FROM LIBFT966.TRAINING_FI_MARITAL_STATUS_DS_BK;
QUIT;
/* Step 2. List the Missing Values in "EMPLOYMENT" Variable */
TITLE 'Before Imputation: ';
TITLE2 'List the missing values';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK e
WHERE ( ( e.EMPLOYMENT EQ '' ) OR
( e.EMPLOYMENT IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "EMPLOYMENT" Variable';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK e
WHERE ( ( e.EMPLOYMENT EQ '' ) OR
( e.EMPLOYMENT IS NULL) );
QUIT;
/* Step 3. Make a copy from current table to Count the Total Observations from Each employment */
TITLE 'Make a copy from current table to Count the Total Observations from Each employment';
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK_NEW AS
SELECT e.EMPLOYMENT AS EMPLOYMENT, COUNT(*) AS TOTAL_COUNTS
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK e
WHERE ( ( e.EMPLOYMENT IS NOT NULL ) OR
( e.EMPLOYMENT NE '' ) )
GROUP BY e.EMPLOYMENT;
QUIT;
/* Step 4. Display the content in new table that has previously created */
TITLE 'Count of Total Observations from Each employment';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK_NEW;
QUIT;
/* Step 5. Find the Maximum Count in new table */
TITLE 'Maximum Count in new table';
PROC SQL;
SELECT MAX(e.TOTAL_COUNTS) AS MAX_COUNTS
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK_NEW e;
QUIT;
/* Step 6. Find the mode for "EMPLOYMENT" variable */
TITLE 'Mode for "EMPLOYMENT" variable';
PROC SQL;
SELECT eo.EMPLOYMENT
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK_NEW eo
WHERE eo.TOTAL_COUNTS EQ ( SELECT MAX(ei.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK_NEW ei);
/* subquery to find the mode for employment */
QUIT;
/* Step 7. Impute the missing values using mode */
TITLE 'Impute the missing values using mode';
PROC SQL;
UPDATE LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK
SET EMPLOYMENT = ( SELECT eo.EMPLOYMENT
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK_NEW eo
WHERE eo.TOTAL_COUNTS EQ ( SELECT MAX(ei.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK_NEW ei ) )
WHERE ( ( EMPLOYMENT IS NULL) OR
( EMPLOYMENT EQ '' ) );
QUIT;
/* Step 8. List the Missing Values in "EMPLOYMENT" Variable after imputation */
TITLE 'After Imputation: ';
TITLE2 'List the missing values after imputation';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK e
WHERE ( ( e.EMPLOYMENT EQ '' ) OR
( e.EMPLOYMENT IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "EMPLOYMENT" Variable after imputation';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK e
WHERE ( ( e.EMPLOYMENT EQ '' ) OR
( e.EMPLOYMENT IS NULL) );
QUIT;
/******************************
LOAN_HISTORY - Categorical Variable
*******************************/
/* Step 1. Make a copy of LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK */
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK AS
SELECT * FROM LIBFT966.TRAINING_FI_EMPLOYMENT_DS_BK;
QUIT;
/* Step 2. List the Missing Values in "LOAN_HISTORY" Variable */
TITLE 'Before Imputation: ';
TITLE2 'List the missing values';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK lh
WHERE ( ( lh.LOAN_HISTORY EQ . ) OR
( lh.LOAN_HISTORY IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "LOAN_HISTORY" Variable';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK lh
WHERE ( ( lh.LOAN_HISTORY EQ . ) OR
( lh.LOAN_HISTORY IS NULL) );
QUIT;
/* Step 3. Make a copy from current table to Count the Total Observations from Each loan history */
TITLE 'Make a copy from current table to Count the Total Observations from Each loan history';
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_LH_DS_BK_NEW AS
SELECT lh.LOAN_HISTORY AS LOAN_HISTORY, COUNT(*) AS TOTAL_COUNTS
FROM LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK lh
WHERE ( ( lh.LOAN_HISTORY IS NOT NULL ) OR
( lh.LOAN_HISTORY NE . ) )
GROUP BY lh.LOAN_HISTORY;
QUIT;
/* Step 4. Display the content in new table that has previously created */
TITLE 'Count of Total Observations from Each loan history';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_LH_DS_BK_NEW;
QUIT;
/* Step 5. Find the Maximum Count in new table */
TITLE 'Maximum Count in new table';
PROC SQL;
SELECT MAX(lh.TOTAL_COUNTS) AS MAX_COUNTS
FROM LIBFT966.TRAINING_FI_LH_DS_BK_NEW lh;
QUIT;
/* Step 6. Find the mode for "LOAN_HISTORY" variable */
TITLE 'Mode for "LOAN_HISTORY" variable';
PROC SQL;
SELECT lho.LOAN_HISTORY
FROM LIBFT966.TRAINING_FI_LH_DS_BK_NEW lho
WHERE lho.TOTAL_COUNTS EQ ( SELECT MAX(lhi.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_LH_DS_BK_NEW lhi);
/* subquery to find the mode for loan history */
QUIT;
/* Step 7. Impute the missing values using mode */
TITLE 'Impute the missing values using mode';
PROC SQL;
UPDATE LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK
SET LOAN_HISTORY = ( SELECT lho.LOAN_HISTORY
FROM LIBFT966.TRAINING_FI_LH_DS_BK_NEW lho
WHERE lho.TOTAL_COUNTS EQ ( SELECT MAX(lhi.TOTAL_COUNTS)
FROM LIBFT966.TRAINING_FI_LH_DS_BK_NEW lhi ) )
WHERE ( ( LOAN_HISTORY IS NULL) OR
( LOAN_HISTORY EQ . ) );
QUIT;
/* Step 8. List the Missing Values in "LOAN_HISTORY" Variable after imputation */
TITLE 'After Imputation: ';
TITLE2 'List the missing values after imputation';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK lh
WHERE ( ( lh.LOAN_HISTORY EQ . ) OR
( lh.LOAN_HISTORY IS NULL) );
QUIT;
TITLE 'Total of Missing Values in "LOAN_HISTORY" Variable after imputation';
PROC SQL;
SELECT COUNT (*) LABEL = 'NUMBER OF MISSING VALUES'
FROM LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK lh
WHERE ( ( lh.LOAN_HISTORY EQ . ) OR
( lh.LOAN_HISTORY IS NULL) );
QUIT;
/************************************************************************
Imputation for continuous variable on dataset LIBFT966.TRAINING_TP061966
*************************************************************************/
/******************************
LOAN_AMOUNT - Continuous Variable
******************************/
/* Step 1. List the missing values in "LOAN_AMOUNT" Variable */
TITLE 'Missing values in "LOAN_AMOUNT" Variable';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK la
WHERE ( la.LOAN_AMOUNT EQ . );
QUIT;
/* Step 2. Count the total of missing values in "LOAN_AMOUNT" Variable */
TITLE 'The total of missing values in "LOAN_AMOUNT" Variable';
PROC SQL;
SELECT COUNT(*) LABEL = 'Total Missing Values'
FROM LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK la
WHERE ( la.LOAN_AMOUNT EQ . );
QUIT;
/* Step 3. SAS Code to make a Copy of the "TRAINING_FI_LOAN_HISTORY_DS_BK" for "LOAN_AMOUNT" Variable Imputation */
TITLE 'Make a Copy of the "TRAINING_FI_LOAN_HISTORY_DS_BK" for "LOAN_AMOUNT" Variable Imputation';
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_LOAN_AMOUNT_DS_BK AS
SELECT * FROM LIBFT966.TRAINING_FI_LOAN_HISTORY_DS_BK;
QUIT;
/* Step 4. Impute the missing values using mean for "LOAN_AMOUNT" variable */
TITLE 'Impute the missing values using mean';
PROC STDIZE DATA = LIBFT966.TRAINING_FI_LOAN_AMOUNT_DS_BK REPONLY
METHOD = MEAN OUT=LIBFT966.TRAINING_FI_LOAN_AMOUNT_DS_BK;
VAR LOAN_AMOUNT;
QUIT;
/******************************
LOAN_DURATION - Continuous Variable
******************************/
/* Step 1. List the missing values in "LOAN_DURATION" Variable */
TITLE 'Missing values in "LOAN_DURATION" Variable';
PROC SQL;
SELECT *
FROM LIBFT966.TRAINING_FI_LOAN_AMOUNT_DS_BK ld
WHERE ( ld.LOAN_DURATION EQ . );
QUIT;
/* Step 2. Count the total of missing values in "LOAN_DURATION" Variable */
TITLE 'The total of missing values in "LOAN_DURATION" Variable';
PROC SQL;
SELECT COUNT(*) LABEL = 'Total Missing Values'
FROM LIBFT966.TRAINING_FI_LOAN_AMOUNT_DS_BK ld
WHERE ( ld.LOAN_DURATION EQ . );
QUIT;
/* Step 3. SAS Code to make a Copy of the "TRAINING_FI_LOAN_AMOUNT_DS_BK" for "LOAN_DURATION" Variable Imputation */
TITLE 'Make a Copy of the "TRAINING_FI_LOAN_AMOUNT_DS_BK" for "LOAN_DURATION" Variable Imputation';
PROC SQL;
CREATE TABLE LIBFT966.TRAINING_FI_LOAN_DURATION_DS_BK AS
SELECT * FROM LIBFT966.TRAINING_FI_LOAN_AMOUNT_DS_BK;
QUIT;
/* Step 4. Impute the missing values using mean for "LOAN_DURATION" variable */
TITLE 'Impute the missing values using mean';
PROC STDIZE DATA = LIBFT966.TRAINING_FI_LOAN_DURATION_DS_BK REPONLY
METHOD = MEAN OUT=LIBFT966.TRAINING_FI_LOAN_DURATION_DS_BK;
VAR LOAN_DURATION;
QUIT;
/*********************************************************************************************
To Create a Copy of "TESTING_DS" Dataset
**********************************************************************************************/
TITLE 'Create a Copy of "TESTING_DS" Dataset';
/* SAS code to create a copy of "TESTING_DS" dataset */
PROC SQL;
CREATE TABLE LIBFT966.TESTING_DS_TP061966_BK AS
SELECT * FROM LIBFT966.TESTING_DS;
QUIT;
/*********************************************************************************************
To create a MACRO for univariate analysis on categorical variable in “TESTING_DS_TP061966_BK”
**********************************************************************************************/