<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Binning  coninous var into categorical var- score card credit risk model in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940224#M369072</link>
    <description>&lt;P&gt;BTW, If you really need 10 groups, then you need make number of iterations (like: 10000 or 100000)&amp;nbsp;very big&lt;BR /&gt;and number of initial individuals(like:&lt;BR /&gt;call gainit(id,10000,encoding);&lt;BR /&gt;) very big&amp;nbsp;&lt;BR /&gt;to make it happen.&lt;BR /&gt;But that would cost you a whole night to run code.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 09:01:29 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-08-21T09:01:29Z</dc:date>
    <item>
      <title>Binning  coninous var into categorical var- score card credit risk model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940218#M369069</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I run a similar code that Mr.Ksharp added in another question I have posted. (Thank you Mr.Ksharp)&lt;/P&gt;
&lt;P&gt;I chose 10 groups and 100 iterations.&lt;/P&gt;
&lt;P&gt;I round the variable to discrete numbers because the numbers can have&amp;nbsp; a decimal value.&lt;/P&gt;
&lt;P&gt;The analyzed variable is&amp;nbsp;&lt;CODE class=" language-sas"&gt;ithalv_expr_snif (Loan&amp;nbsp;balance)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;There&amp;nbsp;is&amp;nbsp;something&amp;nbsp;that&amp;nbsp;I&amp;nbsp;don't&amp;nbsp;understand-&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;I&amp;nbsp;see&amp;nbsp;groups&amp;nbsp;with&amp;nbsp;very&amp;nbsp;low&amp;nbsp;number&amp;nbsp;of&amp;nbsp;customers&amp;nbsp;and&amp;nbsp;also&amp;nbsp;very&amp;nbsp;low&amp;nbsp;number&amp;nbsp;of&amp;nbsp;bads.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;In&amp;nbsp;the&amp;nbsp;code&amp;nbsp;there&amp;nbsp;is&amp;nbsp;condition:&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;if Bad_Dist&amp;gt;0.05 and Good_Dist&amp;gt;0.05 then woe[i]=log(Bad_Dist/Good_Dist);&lt;BR /&gt;else woe[i]=.;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;So&amp;nbsp;I&amp;nbsp;dont&amp;nbsp;understand&amp;nbsp;why&amp;nbsp;such&amp;nbsp;groups&amp;nbsp;were&amp;nbsp;created????&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;Also,&amp;nbsp;I&amp;nbsp;expect&amp;nbsp;that&amp;nbsp;worst&amp;nbsp;group&amp;nbsp;(lowest&amp;nbsp;WOE)&amp;nbsp;be&amp;nbsp;group&amp;nbsp;1&amp;nbsp;and&amp;nbsp;best&amp;nbsp;group&amp;nbsp;be&amp;nbsp;group&amp;nbsp;10.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;In&amp;nbsp;the&amp;nbsp;output&amp;nbsp;groups&amp;nbsp;order&amp;nbsp;is&amp;nbsp;not&amp;nbsp;1&amp;nbsp;to&amp;nbsp;10&amp;nbsp;.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1724228247350.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99495iFDC880632C874971/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1724228247350.png" alt="Ronein_0-1724228247350.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include '!RSMEHOME/SASCode/SHARECode/Libname.sas';

proc delete data=work._all_;Run;

%let var=ithalv_expr_snif ;  *the continuous variable you need to split;
%let group=10 ;    *the number of group you want to bin to;
%let n_iter=100;  *the number of iteration for Genetic Algorithm to get best WOE IV;

Data temp;
set r_r.TatPop_raw_Data_Of1_MB1_2;
good_bad=ifc(KESHEL_FUTURE=0,'good','bad');
IF &amp;amp;var.=. then Var=0;
else Var=round(&amp;amp;Var.,1);
keep VAR   good_bad   KESHEL_FUTURE;
Run;
 

proc sql noprint;
select sum(good_bad='bad'),
        sum(good_bad='good'),
        floor(min(var)),ceil(max(var)) 
        into : n_bad,: n_good,: min,: max
from temp;
quit;
%put n_bad=&amp;amp;n_bad   n_good=&amp;amp;n_good   min=&amp;amp;min   max=&amp;amp;max;


proc sort data=temp;
by var ;
run;


proc iml;
use temp(where=(var is not missing));
read all var {var good_bad};
close;
start function(x) global(bin,var ,good_bad,group,woe);
if countunique(x)=group-1 then do;
col_x=t(x);
call sort(col_x,1);
cutpoints= .M//col_x//.I ;
b=bin(var ,cutpoints,'right');
if countunique(b)=group  then do;
do i=1 to group;
idx=loc(b=i);
temp=good_bad[idx];
n_bad=sum(temp='bad');
n_good=sum(temp='good');
bad_dist=n_bad/&amp;amp;n_bad ; 
good_dist=n_good/&amp;amp;n_good ; 
if Bad_Dist&amp;gt;0.05 and Good_Dist&amp;gt;0.05  then woe[i]=log(Bad_Dist/Good_Dist);
else woe[i]=.;
end;
if countmiss(woe)=0 then do;
/*
xx=j(group,1,1)||woe||woe##2;
*/
xx=j(group,1,1)||woe;
beta=solve(xx`*xx,xx`*bin);
yhat=xx*beta;
sse=ssq(bin-yhat);
end;
else sse=999999;
end;
else sse=999999;
end;
else sse=999999;
return (sse);
finish;
group=&amp;amp;group ;  
bin=t(1:group);
woe=j(group,1,.);

encoding=j(2,group-1,&amp;amp;min );
encoding[2,]=&amp;amp;max ;    
	id=gasetup(2,group-1,123456789);  /***Only for continuous Var (For example- welalth) with integer values****/
call gasetobj(id,0,"function");
call gasetsel(id,10,1,1);
call gainit(id,1000,encoding);

niter =  &amp;amp;n_iter ;
do i = 1 to niter;
 call garegen(id);
 call gagetval(value, id);
end;
call gagetmem(mem, value, id, 1);
col_mem=t(mem);
call sort(col_mem,1);
cutpoints= .M//col_mem//.I ;
b=bin(var ,cutpoints,'right');
create cutpoints var {cutpoints};
append;
close;
create group var {b};
append;
close;
print value[l = "Min Value:"] ;
call gaend(id);
quit;

/*If your variable have decimal point, try the following */
/*multiply your variable by 100 or 1000 and using my original code( integer encoding by 2) like:  */
/*ithalv_expr_snif=100*ithalv_expr_snif;*/



data all_group;
set temp(keep=var rename=(var=b) where=(b is missing)) group;
run;


proc sql noprint;
select count(distinct b) as nr_groups into :nr_groups
from all_group
;
quit;
%put &amp;amp;nr_groups;


data all;
merge all_group temp;
/*b=(&amp;amp;nr_groups.-b)+1; */
/***I want that worse group be group 1 and so on****/
rename b=group;
Run;

title;
title "&amp;amp;var" ;
proc sql;
create table woe_var as
 select group label=' ',
min(var) as min label='min',
max(var) as max label='max',
count(*) as n label='N',
calculated n/(select count(*) from all) as per format=percent7.2 label='N_dist',
sum(good_bad='bad') as n_bad label='n_bad',
sum(good_bad='good') as n_good label='n_good',
sum(good_bad='bad')/(select sum(good_bad='bad') from all ) as bad_dist label='bad_dist' format=percent8.2,
sum(good_bad='good')/(select sum(good_bad='good') from all ) as good_dist label='good_dist' format=percent8.2,
calculated n_bad/calculated N as PCT_BAD label='PCT_Bads' format=percent8.2,
log(calculated Bad_Dist/calculated Good_Dist) as woe
from all
   group by group
    order by woe desc;  /**Worse group first***/
create index group on woe_var;
select *,sum(  (Bad_Dist-Good_Dist)*woe  ) as iv
 from woe_var ;
quit;
title ' ';

 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 08:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940218#M369069</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-08-21T08:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Binning  coninous var into categorical var- score card credit risk model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940222#M369071</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;if Bad_Dist&amp;gt;0.05 and Good_Dist&amp;gt;0.05 then woe[i]=log(Bad_Dist/Good_Dist);"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That&amp;nbsp; means Bad_Dist and Good_Dist are at least 5%.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Therefore, from your output , the result is not right .&lt;/SPAN&gt;&lt;SPAN&gt;(Bad_Dist and Good_Dist 's value must be greater than 5%)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And in output of my code, you will see a MIN VALUE:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1724229011255.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99496i9323AD0E26ABBA69/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1724229011255.png" alt="Ksharp_0-1724229011255.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That stands for an ERROR term of GA. That means if it is near zero,the model is better,and you got GOOD bin/result.&lt;/P&gt;
&lt;P&gt;And I guess your Min Value was very big.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The last thing is the number of groups you are binning is too big.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general , 6 or 7 groups is good enough to get desired result.&lt;/P&gt;
&lt;P&gt;Thus, choose&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;5 or 6&amp;nbsp;groups to get useful result.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 08:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940222#M369071</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-21T08:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Binning  coninous var into categorical var- score card credit risk model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940224#M369072</link>
      <description>&lt;P&gt;BTW, If you really need 10 groups, then you need make number of iterations (like: 10000 or 100000)&amp;nbsp;very big&lt;BR /&gt;and number of initial individuals(like:&lt;BR /&gt;call gainit(id,10000,encoding);&lt;BR /&gt;) very big&amp;nbsp;&lt;BR /&gt;to make it happen.&lt;BR /&gt;But that would cost you a whole night to run code.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 09:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940224#M369072</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-21T09:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Binning  coninous var into categorical var- score card credit risk model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940230#M369073</link>
      <description>&lt;P&gt;Minimum value of the analyzed variable is 0.&lt;/P&gt;
&lt;P&gt;Maximum value of the analyzed variable is&amp;nbsp; &amp;nbsp;&amp;nbsp;698163&lt;/P&gt;
&lt;P&gt;I was asked to add also condition that minimum bads in a group is 100.&lt;/P&gt;
&lt;P&gt;I run the code on 5 groups and 100 iterations.&lt;/P&gt;
&lt;P&gt;Still get same problem&lt;/P&gt;
&lt;P&gt;Here is the full code I run:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;maybe something in my code is faulty???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include '!RSMEHOME/SASCode/SHARECode/Libname.sas';

proc delete data=work._all_;Run;

%let var=ithalv_expr_snif ;  *the continuous variable you need to split;
%let group=5 ;    *the number of group you want to bin to;
%let n_iter=100;  *the number of iteration for Genetic Algorithm to get best WOE IV;

Data temp;
set r_r.TatPop_raw_Data_Of1_MB1_2;
good_bad=ifc(KESHEL_FUTURE=0,'good','bad');
IF &amp;amp;var.=. then Var=0;
else Var=round(&amp;amp;Var.,1);
keep VAR   good_bad   KESHEL_FUTURE;
Run;
 
 

proc sql noprint;
select sum(good_bad='bad'),
        sum(good_bad='good'),
        floor(min(var)),ceil(max(var)) 
        into : n_bad,: n_good,: min,: max
from temp;
quit;
%put n_bad=&amp;amp;n_bad   n_good=&amp;amp;n_good   min=&amp;amp;min   max=&amp;amp;max;


proc sort data=temp;
by var ;
run;

 

proc iml;
use temp;
read all var {var good_bad};
close;
start function(x) global(bin,var,good_bad,group,woe);
if countunique(x)=group-1 then do;
col_x=t(x);
call sort(col_x,1);
cutpoints= .M//col_x//.I ;
b=bin(var,cutpoints,'right');
if countunique(b)=group  then do;
do i=1 to group;
idx=loc(b=i);
temp=good_bad[idx];
n_bad=sum(temp='bad');
n_good=sum(temp='good');
bad_dist=n_bad/&amp;amp;n_bad ; 
good_dist=n_good/&amp;amp;n_good ; 
if Bad_Dist&amp;gt;0.05 &amp;amp; Good_Dist&amp;gt;0.05 &amp;amp; n_bad&amp;gt;=100 then woe[i]=log(Bad_Dist/Good_Dist);
else woe[i]=.;
end;
if countmiss(woe)=0 then do;
/*
xx=j(group,1,1)||woe||woe##2;
*/
xx=j(group,1,1)||woe;
beta=solve(xx`*xx,xx`*bin);
yhat=xx*beta;
sse=ssq(bin-yhat);
end;
else sse=999999;
end;
else sse=999999;
end;
else sse=999999;
return (sse);
finish;
group=&amp;amp;group ;  
bin=t(1:group);
woe=j(group,1,.);

encoding=j(2,group-1,&amp;amp;min );
encoding[2,]=&amp;amp;max ;    
	id=gasetup(2,group-1,123456789);  /***Only for continuous Var (For example- welalth) with integer values****/
call gasetobj(id,0,"function");
call gasetsel(id,10,1,1);
call gainit(id,1000,encoding);

niter =  &amp;amp;n_iter ;
do i = 1 to niter;
 call garegen(id);
 call gagetval(value, id);
end;
call gagetmem(mem, value, id, 1);
col_mem=t(mem);
call sort(col_mem,1);
cutpoints= .M//col_mem//.I ;
b=bin(var,cutpoints,'right');
create cutpoints var {cutpoints};
append;
close;
create group var {b};
append;
close;
print value[l = "Min Value:"] ;
call gaend(id);
quit;

/*If your variable have decimal point, try the following */
/*multiply your variable by 100 or 1000 and using my original code( integer encoding by 2) like:  */
/*ithalv_expr_snif=100*ithalv_expr_snif;*/



data all_group;
set temp(keep=var rename=(var=b) where=(b is missing)) group;
run;


proc sql noprint;
select count(distinct b) as nr_groups into :nr_groups
from all_group
;
quit;
%put &amp;amp;nr_groups;


data all;
merge all_group temp;
/*b=(&amp;amp;nr_groups.-b)+1; */
/***I want that worse group be group 1 and so on****/
rename b=group;
Run;

title;
title "&amp;amp;var" ;
proc sql;
create table woe_var as
 select group label=' ',
min(var) as min label='min',
max(var) as max label='max',
count(*) as n label='N',
calculated n/(select count(*) from all) as per format=percent7.2 label='N_dist',
sum(good_bad='bad') as n_bad label='n_bad',
sum(good_bad='good') as n_good label='n_good',
sum(good_bad='bad')/(select sum(good_bad='bad') from all ) as bad_dist label='bad_dist' format=percent8.2,
sum(good_bad='good')/(select sum(good_bad='good') from all ) as good_dist label='good_dist' format=percent8.2,
calculated n_bad/calculated N as PCT_BAD label='PCT_Bads' format=percent8.2,
log(calculated Bad_Dist/calculated Good_Dist) as woe
from all
   group by group
    order by woe desc;  /**Worse group first***/
create index group on woe_var;
select *,sum(  (Bad_Dist-Good_Dist)*woe  ) as iv
 from woe_var ;
quit;
title ' ';

 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the output&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1724231088200.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99502i14FFCE93D50FCC6D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1724231088200.png" alt="Ronein_0-1724231088200.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 09:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940230#M369073</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-08-21T09:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Binning  coninous var into categorical var- score card credit risk model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940249#M369076</link>
      <description>1)Post your Min Value I mentioned above.&lt;BR /&gt;I guess it is 999999.&lt;BR /&gt;2) You change my code ? Why ? Don't change my code unless you know SAS/IML syntax.&lt;BR /&gt;if Bad_Dist&amp;gt;0.05 &amp;amp; Good_Dist&amp;gt;0.05 &amp;amp; n_bad&amp;gt;=100 then&lt;BR /&gt;--&amp;gt;&lt;BR /&gt;if n_good&amp;gt;0 &amp;amp;  n_bad&amp;gt;100 then&lt;BR /&gt;&lt;BR /&gt;2) DO NOT CHANGE MY CODE.&lt;BR /&gt;&lt;BR /&gt;3）Make the following number as big as you can. So you can get what you want.&lt;BR /&gt;%let n_iter=10000; &lt;BR /&gt;call gainit(id,10000,encoding);</description>
      <pubDate>Wed, 21 Aug 2024 09:23:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940249#M369076</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-21T09:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Binning  coninous var into categorical var- score card credit risk model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940258#M369077</link>
      <description>"&lt;BR /&gt;Minimum value of the analyzed variable is 0.&lt;BR /&gt;&lt;BR /&gt;Maximum value of the analyzed variable is    698163&lt;BR /&gt;"&lt;BR /&gt;&lt;BR /&gt;One more thing:&lt;BR /&gt;Post a Histogram Graphic by &lt;BR /&gt;proc univariate .....&lt;BR /&gt;histogram ithalv_expr_snif ;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;And If I was right. you got a HEAVY LONG tail . That is not good for GA.&lt;BR /&gt;You can truncate/winsorize it to make my code more efficient and could get you better result. Like:&lt;BR /&gt;Data temp;&lt;BR /&gt;set r_r.TatPop_raw_Data_Of1_MB1_2;&lt;BR /&gt;......................&lt;BR /&gt;if ithalv_expr_snif &amp;gt;20000 then ithalv_expr_snif =20000;</description>
      <pubDate>Wed, 21 Aug 2024 09:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940258#M369077</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-21T09:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Binning  coninous var into categorical var- score card credit risk model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940259#M369078</link>
      <description>Firstly ,Try to use my original code.&lt;BR /&gt;DO NOT change my code !&lt;BR /&gt;&lt;BR /&gt;After you truncated/winsorized variable "ithalv_expr_snif " as I showed above and use my ORIGINAL code , I believe you will get the desired result .</description>
      <pubDate>Wed, 21 Aug 2024 09:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940259#M369078</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-21T09:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Binning  coninous var into categorical var- score card credit risk model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940420#M369125</link>
      <description>&lt;P&gt;If your histogram graphic is long heavy tail , you should truncated or winsorized your data, like: (mentioned above)&lt;/P&gt;
&lt;PRE&gt;Data temp; 
set r_r.TatPop_raw_Data_Of1_MB1_2; 
...................... 
if ithalv_expr_snif &amp;gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;20000&lt;/STRONG&gt; &lt;/FONT&gt;then ithalv_expr_snif =&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;20000&lt;/STRONG&gt;&lt;/FONT&gt;;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&amp;nbsp;Here, 20000 should be 95% percentile of ithalv_expr_snif variable (or less than 95% percentile).&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;After that, I thing you will get desired output!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 00:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binning-coninous-var-into-categorical-var-score-card-credit-risk/m-p/940420#M369125</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-22T00:19:47Z</dc:date>
    </item>
  </channel>
</rss>

