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?
Thanks in adavnce,
Andreas
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=' '; label good_bad='实际值' _status='预测值'; 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 ; class good_bad; var total_score; run; title ' '; /*********** Graph for Score Card *************/ data plot_bad_percent; 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; format percent_bad percent7.2; run;
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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.