Pyrite | Level 9

## Scorecard Node in SAS Viya 3.5 - Kolmogorov - Smirnov chart/ Cutoff Score

Spoiler

Hi!

I am using the scorecard node in SAS Viya 3.5. Is there somewhere the chart with the KS statistic in the vertical axis and the scorecard cutoff score in the horizontal axis (to get the optimal scorecard cut off) as it was in SAS EM scorecard node?

Andreas

7 REPLIES 7
Pyrite | Level 9

## Re: Scorecard Node in SAS Viya 3.5 - Kolmogorov - Smirnov chart/ Cutoff Score

If not where can we see the cutoff score used by the node to classify goods from bads?
Super User

## Re: Scorecard Node in SAS Viya 3.5 - Kolmogorov - Smirnov chart/ Cutoff Score

cutoff score is making confusion matrix most distinguish(or when K-S statistic is max) .
you could also wrote data step to get it .
Pyrite | Level 9

## Re: Scorecard Node in SAS Viya 3.5 - Kolmogorov - Smirnov chart/ Cutoff Score

Can we see at which score the KS statistic is max in a graph e.g. ROC curve?
Super User

## Re: Scorecard Node in SAS Viya 3.5 - Kolmogorov - Smirnov chart/ Cutoff Score

Here is the code I wrote before to get max K-S value .

Note: using all data you can get  . Not the training data of building scorecard.

```/****** Get cutpoint ******/
proc delete data=cutpoint;run;
%macro cutpoint;
%do score=&score_min %to &score_max;
data test_total_score;
set score_card;
_status=ifc(total_score ge &score,'good','bad ');
run;
proc npar1way data=test_total_score edf noprint;
class _status;
var total_score;
output out=cutpoint_ks(keep=_KS_) edf;
run;
data temp_cutpoint;
retain cutpoint &score ;
set cutpoint_ks ;
label cutpoint='分割点' _ks_='KS值';
run;
proc append base=cutpoint data=temp_cutpoint force;run;
%end;
%mend;

%cutpoint

proc sql noprint;
select cutpoint into : cutpoint
from cutpoint
having _KS_=max(_KS_);
quit;
data _null_;
set cutpoint end=last;
if _n_=1 then call symputx('min',cutpoint);
if last then call symputx('max',cutpoint);
run;

data final_total_score;
set score_card;
*_status=ifc(total_score ge &cutpoint,'good','bad ');
run;

/*********** Confused Matrix  **********/
/*********** Also Check Validate Table **********/
title "训练集分割点为 &cutpoint 的混淆矩阵 - Confused Matrix";
proc freq data=final_total_score  ;
table good_bad*_status/nopercent  norow  contents=' ';
run;
title ' ';

/********* Graph for cutpoint and KS value *************/
data plot_cutpoint;
set cutpoint;
if cutpoint=&cutpoint then group=1;
else group=0;
run;
proc sgplot data=plot_cutpoint noautolegend;
needle x=cutpoint y=_ks_ /group=group ;
yaxis  LABELATTRS=graphdata1 VALUEATTRS=graphdata1 ;
xaxis values=(&min &cutpoint &max);
run;

title "KS检验";
proc npar1way data=final_total_score plots=edfplot edf ;
var total_score;
run;
title ' ';

/*********** Graph for Score Card  *************/
set report;
length range \$ 40;
range=cats('[',put(int(min),8.0),',',put(int(max),8.0),']');
run;

proc sgplot data=plot_bad_percent ;
series x=range y=percent_bad/datalabel markers MARKERATTRS=(symbol=circlefilled
size=12) MARKERFILLATTRS=(color=white) MARKEROUTLINEATTRS=graphdata1
FILLEDOUTLINEDMARKERS DATALABELPOS=right datalabelattrs=(size=10);
xaxistable n_good n /valueattrs=(size=10);
label n='人数' ;
xaxis  FITPOLICY=stagger label='评分' labelposition=left
LABELATTRS=graphdata1 VALUEATTRS=graphdata1(size=10) grid;
run;
```
Pyrite | Level 9

## Re: Scorecard Node in SAS Viya 3.5 - Kolmogorov - Smirnov chart/ Cutoff Score

I was wondering wether there is a ROC curve graph to see the KS statistics like there was in SAS EM Credit Scoring nodes.

Thanks,

Andreas
Super User

## Re: Scorecard Node in SAS Viya 3.5 - Kolmogorov - Smirnov chart/ Cutoff Score

I don't understand.

You want this ?

``````proc logistic data=sashelp.class;
model sex=weight height/outroc=roc ;
run;

proc sgplot data=roc aspect=1 noautolegend;
series y=_SENSIT_ x=_1MSPEC_;
lineparm x=0 y=0 slope=1;
inset 'KS=0.324';
run;``````

Pyrite | Level 9

## Re: Scorecard Node in SAS Viya 3.5 - Kolmogorov - Smirnov chart/ Cutoff Score

Hi!

I wanted this as a standard output in SAS VDMM (without having to wrote sas code).

BR,

Andreas
Discussion stats
• 7 replies
• 1116 views
• 3 likes
• 2 in conversation