<?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: SAS Error when Calculating Information Value - Please Help Thank you in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Error-when-Calculating-Information-Value-Please-Help-Thank/m-p/209818#M51982</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry this is the code that's creating errors /**********************************/ /*INFORMATION VALUE CALCULATION*/ /*******************************/ DATA META_VARIABLESET;&amp;nbsp;&amp;nbsp; SET EMWS2.META_VARIABLESET&amp;nbsp;&amp;nbsp;&amp;nbsp; (KEEP=NAME NEWROLE);&amp;nbsp;&amp;nbsp; WHERE NEWROLE NE 'REJECTED'; RUN; proc sql noprint;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct name into :all_vars separated by ' ' from META_VARIABLESET; select count(*) into :num_vars from META_VARIABLESET; quit; %put There are --&amp;amp;num_vars.-- variables, listed below...; %put --&amp;amp;all_vars.--; /********************************/ /*Information Value Calculation*/ /******************************/ /* Check levels */ %let tiers = 10; ods output nlevels=checkfreq; proc&amp;nbsp; freq data=TRAINING nlevels; tables &amp;amp;all_vars. /noprint; run ; ods output close; 　 data&amp;nbsp; usevars; set checkfreq; where nlevels &amp;gt;= &amp;amp;tiers.; row_num = _n_; length str_var $34; str_var = strip(cat("'", strip(tablevar), "'")); run ; %macro woe_prep; proc sql noprint; select count(*) into :max_iters from usevars; quit; %put &amp;amp;max_iters.; %do i = 1 %to &amp;amp;max_iters.; proc sql noprint; select tablevar, str_var into :a, &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt; from usevars where row_num = &amp;amp; i.; quit; %let this_var = &amp;amp;a.; %let str_var = &amp;amp;b.; %put &amp;amp;this_var.; %put &amp;amp;str_var.; data temp; length tablevar $32.; set TRAINING (keep = TARGET &amp;amp;this_var.); tablevar = &amp;amp; str_var.; run; proc rank data=temp out=temp groups=&amp;amp; tiers.; var &amp;amp; this_var.; ranks var_rank; run; proc sql; create table temp2 as select tablevar, var_rank, avg(&amp;amp; this_var.) as mean_origv, min(&amp;amp; this_var.) as min_origv, max(&amp;amp; this_var.) as max_origv, count(*) as custs, sum(case when target = 1 then 1 else 0 end) as good, sum(case when target = 0 then 1 else 0 end) as bad, sum(case when &amp;amp; this_var. = . then 1 else 0 end) as miss_val from temp group by 1, 2 order by 1, 2; quit; %if &amp;amp;i. = 1 %then %do; data outstack; set temp2; run; %end; %if &amp;amp;i. &amp;gt;= 2 %then %do; data outstack; set outstack temp2; run; %end; %end; %mend woe_prep; 　 %woe_prep; 　 proc sql; create table outstack_tots as select tablevar, sum(custs) as tot_custs, sum(good) as tot_good, sum(bad) as tot_bad, sum(miss_val) as tot_miss from outstack group by 1 order by 1; quit ; 　 proc sort data=outstack; by tablevar var_rank; run ; proc sort data=outstack_tots; by tablevar; run ; 　 data woe; merge outstack outstack_tots; by tablevar; dist_good = good / tot_good; dist_bad = bad / tot_bad; woe = log(dist_good / dist_bad) * 100; pre_iv = (dist_good - dist_bad) * log(dist_good / dist_bad); run ; 　 proc sql; create table iv as select tablevar, sum(pre_iv) as iv, sum(good) as tot_good, sum(bad) as tot_bad, sum(custs) as tot_custs, sum(miss_val) as tot_miss from woe group by 1 order by 2 desc; quit ; 　 　 　 proc npar1way data=MT.BNA_HC_BGRE_BUILD_BALANCED edf noprint; var &amp;amp;all_vars.; class target; output out=ks_out (keep= _var_ _D_ rename=(_var_=tablevar _D_=ks)); run ; proc sort data=ks_out; by tablevar; run ; proc sort data=iv; by tablevar; run ; 　 data &amp;amp;init._iv_&amp;amp;model._&amp;amp;vers.; merge iv (in=a) ks_out; by tablevar; if a = 1; run ; 　 proc sort data=&amp;amp;init._iv_&amp;amp;model._&amp;amp;vers.; by descending iv; run&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Mar 2015 11:53:10 GMT</pubDate>
    <dc:creator>Kanyange</dc:creator>
    <dc:date>2015-03-25T11:53:10Z</dc:date>
    <item>
      <title>SAS Error when Calculating Information Value - Please Help Thank you</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Error-when-Calculating-Information-Value-Please-Help-Thank/m-p/209817#M51981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi , I was trying to run the code below but get an error from SAS . I have attache the error I get as it is a long one..Basically it says Failed to transcode data from U_UTF8_CE to U_LATIN1_CE enconding because it contained characters which arenot supported by your SAS session encoding. A portion of the source string, in hex representation is [None] 2ae03e396874 : 3b 2a 27 3b 2a 22 2a 2f 3b 71 75 69 74 3b 72 |;*;*/; quit; r| Some code points did not transcode etc.. Below is the code that's giving me errors&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2015 11:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Error-when-Calculating-Information-Value-Please-Help-Thank/m-p/209817#M51981</guid>
      <dc:creator>Kanyange</dc:creator>
      <dc:date>2015-03-25T11:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Error when Calculating Information Value - Please Help Thank you</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Error-when-Calculating-Information-Value-Please-Help-Thank/m-p/209818#M51982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry this is the code that's creating errors /**********************************/ /*INFORMATION VALUE CALCULATION*/ /*******************************/ DATA META_VARIABLESET;&amp;nbsp;&amp;nbsp; SET EMWS2.META_VARIABLESET&amp;nbsp;&amp;nbsp;&amp;nbsp; (KEEP=NAME NEWROLE);&amp;nbsp;&amp;nbsp; WHERE NEWROLE NE 'REJECTED'; RUN; proc sql noprint;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct name into :all_vars separated by ' ' from META_VARIABLESET; select count(*) into :num_vars from META_VARIABLESET; quit; %put There are --&amp;amp;num_vars.-- variables, listed below...; %put --&amp;amp;all_vars.--; /********************************/ /*Information Value Calculation*/ /******************************/ /* Check levels */ %let tiers = 10; ods output nlevels=checkfreq; proc&amp;nbsp; freq data=TRAINING nlevels; tables &amp;amp;all_vars. /noprint; run ; ods output close; 　 data&amp;nbsp; usevars; set checkfreq; where nlevels &amp;gt;= &amp;amp;tiers.; row_num = _n_; length str_var $34; str_var = strip(cat("'", strip(tablevar), "'")); run ; %macro woe_prep; proc sql noprint; select count(*) into :max_iters from usevars; quit; %put &amp;amp;max_iters.; %do i = 1 %to &amp;amp;max_iters.; proc sql noprint; select tablevar, str_var into :a, &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt; from usevars where row_num = &amp;amp; i.; quit; %let this_var = &amp;amp;a.; %let str_var = &amp;amp;b.; %put &amp;amp;this_var.; %put &amp;amp;str_var.; data temp; length tablevar $32.; set TRAINING (keep = TARGET &amp;amp;this_var.); tablevar = &amp;amp; str_var.; run; proc rank data=temp out=temp groups=&amp;amp; tiers.; var &amp;amp; this_var.; ranks var_rank; run; proc sql; create table temp2 as select tablevar, var_rank, avg(&amp;amp; this_var.) as mean_origv, min(&amp;amp; this_var.) as min_origv, max(&amp;amp; this_var.) as max_origv, count(*) as custs, sum(case when target = 1 then 1 else 0 end) as good, sum(case when target = 0 then 1 else 0 end) as bad, sum(case when &amp;amp; this_var. = . then 1 else 0 end) as miss_val from temp group by 1, 2 order by 1, 2; quit; %if &amp;amp;i. = 1 %then %do; data outstack; set temp2; run; %end; %if &amp;amp;i. &amp;gt;= 2 %then %do; data outstack; set outstack temp2; run; %end; %end; %mend woe_prep; 　 %woe_prep; 　 proc sql; create table outstack_tots as select tablevar, sum(custs) as tot_custs, sum(good) as tot_good, sum(bad) as tot_bad, sum(miss_val) as tot_miss from outstack group by 1 order by 1; quit ; 　 proc sort data=outstack; by tablevar var_rank; run ; proc sort data=outstack_tots; by tablevar; run ; 　 data woe; merge outstack outstack_tots; by tablevar; dist_good = good / tot_good; dist_bad = bad / tot_bad; woe = log(dist_good / dist_bad) * 100; pre_iv = (dist_good - dist_bad) * log(dist_good / dist_bad); run ; 　 proc sql; create table iv as select tablevar, sum(pre_iv) as iv, sum(good) as tot_good, sum(bad) as tot_bad, sum(custs) as tot_custs, sum(miss_val) as tot_miss from woe group by 1 order by 2 desc; quit ; 　 　 　 proc npar1way data=MT.BNA_HC_BGRE_BUILD_BALANCED edf noprint; var &amp;amp;all_vars.; class target; output out=ks_out (keep= _var_ _D_ rename=(_var_=tablevar _D_=ks)); run ; proc sort data=ks_out; by tablevar; run ; proc sort data=iv; by tablevar; run ; 　 data &amp;amp;init._iv_&amp;amp;model._&amp;amp;vers.; merge iv (in=a) ks_out; by tablevar; if a = 1; run ; 　 proc sort data=&amp;amp;init._iv_&amp;amp;model._&amp;amp;vers.; by descending iv; run&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2015 11:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Error-when-Calculating-Information-Value-Please-Help-Thank/m-p/209818#M51982</guid>
      <dc:creator>Kanyange</dc:creator>
      <dc:date>2015-03-25T11:53:10Z</dc:date>
    </item>
  </channel>
</rss>

