<?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: Replacing Variables by WoE in Logistic Regression in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Variables-by-WoE-in-Logistic-Regression/m-p/559950#M156440</link>
    <description>&lt;P&gt;I would use PROC FORMAT . Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data fmt_&amp;amp;var ;
 set cutpoints;
 start=lag(cutpoints);
 end=cutpoints;
 if start=.M then hlo='IL';
 if end=.I then hlo='IH';
 if _n_ ne 1 then do;group+1;output;end;
run;
data fmt_&amp;amp;var(index=(group));
 merge  fmt_&amp;amp;var woe_&amp;amp;var(keep=group woe);
 by group;
 retain fmtname "&amp;amp;var" type 'I';
 keep group fmtname type start end woe hlo;
 rename woe=label;
 label group=' ';
run;
proc format cntlin=fmt_&amp;amp;var library=z;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options fmtsearch=(z);
data want;
 set have;
 woe_age=input(age,age.);
 woe_sex=input(sex,sex.);
 woe_client_s=input(client_s,client_s.);
 woe_version=input(version,version.);
 woe_interset=input(interset,interset.);
 woe_insure_y=input(insure_y,insure_y.);
 woe_gps=input(gps,gps.);
 woe_brand=input(brand,brand.);
 woe_up_brand=input(up_brand,up_brand.);
 woe_shop_p=input(shop_p,shop_p.);
 woe_brand_p=input(brand_p,brand_p.);
 woe_birth_p=input(birth_p,birth_p.);
 woe_rent=input(rent,rent.);
 woe_first_p=input(first_p,first_p.);
 woe_tax=input(tax,tax.);
 woe_capital=input(capital,capital.);
 woe_from_s=input(from_s,from_s.);
 woe_price_c=input(price_c,price_c.);
 woe_price_p=input(price_p,price_p.);
 *woe_ratio_f=input(ratio_f,ratio_f.);
 woe_insurea=input(insurea,insurea.);
 woe_insureb=input(insureb,insureb.);


 woe_cont_n=input(cont_n,cont_n.);
 woe_marry=input(marry,marry.);
 woe_pay_way=input(pay_way,pay_way.);
 woe_insure_w=input(insure_w,insure_w.);
 woe_bussines=input(bussines,bussines.);
 woe_culture=input(culture,culture.);
 woe_group_c=input(group_c,group_c.);
 woe_duty=input(duty,duty.);
 woe_car_usag=input(car_usag,car_usag.);
 woe_icompany=input(icompany,icompany.);
 woe_cont_a_n=input(cont_a_n,cont_a_n.);
 woe_nation=input(nation,nation.);

run;












/******Firstly,Check Multicollinearity***********/
%let varlist= 
woe_sex
woe_client_s
woe_interset
woe_insure_y
woe_gps
woe_brand
woe_shop_p
woe_rent
woe_first_p
woe_cont_n
woe_marry
woe_culture
woe_nation
;



%let n=%sysfunc(countw(&amp;amp;varlist,%str( )));
%put &amp;amp;n ;

proc logistic data=want outest=est(keep=intercept &amp;amp;varlist);
model good_bad(event='good')= &amp;amp;varlist 
/outroc=x.roc lackfit scale=none aggregate rsquare  firth corrb  /* selection=stepwise sle=0.1 sls=0.1*/ ;
output out=output h=h c=c cbar=cbar predicted=PredProb;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you are sas rookie, you could write it by hand, something like :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if missing(age) then woe_age=0.213;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else if age&amp;lt;20 then woe_age=0.342;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;else woe_age=0.4345;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if missing(sex) then woe_sex=0.234;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; else if sex='F' then woe_sex=0.456;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else if sex='M' then woe_sex=0.675;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Sun, 19 May 2019 12:34:56 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-05-19T12:34:56Z</dc:date>
    <item>
      <title>Replacing Variables by WoE in Logistic Regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Variables-by-WoE-in-Logistic-Regression/m-p/559897#M156422</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to&amp;nbsp;Replacing Variables by WoE (Weight of Evidence) in Logistic Regression in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sas enterprise miner gives a conveient way to do this, but how to do it in sas 9.4? Can you please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2019 15:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-Variables-by-WoE-in-Logistic-Regression/m-p/559897#M156422</guid>
      <dc:creator>asifgeneral</dc:creator>
      <dc:date>2019-05-18T15:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing Variables by WoE in Logistic Regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Variables-by-WoE-in-Logistic-Regression/m-p/559922#M156434</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/217926"&gt;@asifgeneral&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to&amp;nbsp;Replacing Variables by WoE (Weight of Evidence) in Logistic Regression in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sas enterprise miner gives a conveient way to do this, but how to do it in sas 9.4? Can you please help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is the question really about how to compute the WOE? Or is the question really how to replace the values of a variable, as it says?&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2019 22:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-Variables-by-WoE-in-Logistic-Regression/m-p/559922#M156434</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-18T22:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing Variables by WoE in Logistic Regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Variables-by-WoE-in-Logistic-Regression/m-p/559950#M156440</link>
      <description>&lt;P&gt;I would use PROC FORMAT . Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data fmt_&amp;amp;var ;
 set cutpoints;
 start=lag(cutpoints);
 end=cutpoints;
 if start=.M then hlo='IL';
 if end=.I then hlo='IH';
 if _n_ ne 1 then do;group+1;output;end;
run;
data fmt_&amp;amp;var(index=(group));
 merge  fmt_&amp;amp;var woe_&amp;amp;var(keep=group woe);
 by group;
 retain fmtname "&amp;amp;var" type 'I';
 keep group fmtname type start end woe hlo;
 rename woe=label;
 label group=' ';
run;
proc format cntlin=fmt_&amp;amp;var library=z;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options fmtsearch=(z);
data want;
 set have;
 woe_age=input(age,age.);
 woe_sex=input(sex,sex.);
 woe_client_s=input(client_s,client_s.);
 woe_version=input(version,version.);
 woe_interset=input(interset,interset.);
 woe_insure_y=input(insure_y,insure_y.);
 woe_gps=input(gps,gps.);
 woe_brand=input(brand,brand.);
 woe_up_brand=input(up_brand,up_brand.);
 woe_shop_p=input(shop_p,shop_p.);
 woe_brand_p=input(brand_p,brand_p.);
 woe_birth_p=input(birth_p,birth_p.);
 woe_rent=input(rent,rent.);
 woe_first_p=input(first_p,first_p.);
 woe_tax=input(tax,tax.);
 woe_capital=input(capital,capital.);
 woe_from_s=input(from_s,from_s.);
 woe_price_c=input(price_c,price_c.);
 woe_price_p=input(price_p,price_p.);
 *woe_ratio_f=input(ratio_f,ratio_f.);
 woe_insurea=input(insurea,insurea.);
 woe_insureb=input(insureb,insureb.);


 woe_cont_n=input(cont_n,cont_n.);
 woe_marry=input(marry,marry.);
 woe_pay_way=input(pay_way,pay_way.);
 woe_insure_w=input(insure_w,insure_w.);
 woe_bussines=input(bussines,bussines.);
 woe_culture=input(culture,culture.);
 woe_group_c=input(group_c,group_c.);
 woe_duty=input(duty,duty.);
 woe_car_usag=input(car_usag,car_usag.);
 woe_icompany=input(icompany,icompany.);
 woe_cont_a_n=input(cont_a_n,cont_a_n.);
 woe_nation=input(nation,nation.);

run;












/******Firstly,Check Multicollinearity***********/
%let varlist= 
woe_sex
woe_client_s
woe_interset
woe_insure_y
woe_gps
woe_brand
woe_shop_p
woe_rent
woe_first_p
woe_cont_n
woe_marry
woe_culture
woe_nation
;



%let n=%sysfunc(countw(&amp;amp;varlist,%str( )));
%put &amp;amp;n ;

proc logistic data=want outest=est(keep=intercept &amp;amp;varlist);
model good_bad(event='good')= &amp;amp;varlist 
/outroc=x.roc lackfit scale=none aggregate rsquare  firth corrb  /* selection=stepwise sle=0.1 sls=0.1*/ ;
output out=output h=h c=c cbar=cbar predicted=PredProb;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you are sas rookie, you could write it by hand, something like :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if missing(age) then woe_age=0.213;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else if age&amp;lt;20 then woe_age=0.342;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;else woe_age=0.4345;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if missing(sex) then woe_sex=0.234;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; else if sex='F' then woe_sex=0.456;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else if sex='M' then woe_sex=0.675;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 19 May 2019 12:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-Variables-by-WoE-in-Logistic-Regression/m-p/559950#M156440</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-05-19T12:34:56Z</dc:date>
    </item>
  </channel>
</rss>

