<?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: How to calculate AUC in this case? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/670246#M201164</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for this post. However, I have a technical question:&lt;/P&gt;&lt;P&gt;i'snt ROC calculated/graphed by calculating sensitivity and FP rate for different cut-offs? what I am trying to say is that in this case when we don't know how the model looks like and all we know is the credit score&amp;nbsp; how can we calculate&amp;nbsp; the number of TP and FP for different cut-offs?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jul 2020 02:33:25 GMT</pubDate>
    <dc:creator>shidehrafigh</dc:creator>
    <dc:date>2020-07-18T02:33:25Z</dc:date>
    <item>
      <title>How to calculate AUC in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/515900#M139282</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was asked to verify a risk-score vendor and had 5000 samples with three variables： Client_ID, Bad_flag (0 for good clients, 1 for default ones) and risk_score (range from 300&amp;nbsp;to 500).&amp;nbsp;The vendor refused to give the&amp;nbsp;formula of the risk_score.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder&amp;nbsp;if there is any function I can use to calculate AUC in this case by SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please enlighten me and thank you indeed!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 06:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/515900#M139282</guid>
      <dc:creator>aegeangu</dc:creator>
      <dc:date>2018-11-26T06:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate AUC in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/515910#M139287</link>
      <description>&lt;P&gt;I would start by in identifying what software you are using, e.g. Enterprise Guide etc., then explain what AUC means (as I expect it means something different to what it means in my industry).&amp;nbsp; Then show some test data in the form of a datastep:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And show what the output should look like, or explain further.&lt;/P&gt;
&lt;P&gt;To my mind if the vendor will not give you a formula, then its going to be very hard to replicate what they have done.&amp;nbsp; I mean something simple like removing or keeping missings can drastically change results, so you need to know the rules they have used as well.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 08:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/515910#M139287</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-26T08:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate AUC in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/515957#M139308</link>
      <description>&lt;P&gt;There is a convenient way to get ROC curve and its value. mentioned by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc logistic data=have ;&lt;/P&gt;
&lt;P&gt;model&amp;nbsp;&lt;SPAN&gt;Bad_flag(event='1')=risk_score /nofit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;roc 'Expected ROC' pred=risk_score;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&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;P&gt;&lt;SPAN&gt;If your SAS is old try this code;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data have;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;set have;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;dummy=1;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;proc logistic data=have ;&lt;/P&gt;
&lt;P&gt;model&amp;nbsp;&lt;SPAN&gt;Bad_flag(event='1')=risk_score dummy /nofit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;roc 'Expected ROC' pred=risk_score;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;roc 'Dummy ROC' pred=dummy ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 12:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/515957#M139308</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-26T12:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate AUC in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/670246#M201164</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for this post. However, I have a technical question:&lt;/P&gt;&lt;P&gt;i'snt ROC calculated/graphed by calculating sensitivity and FP rate for different cut-offs? what I am trying to say is that in this case when we don't know how the model looks like and all we know is the credit score&amp;nbsp; how can we calculate&amp;nbsp; the number of TP and FP for different cut-offs?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 02:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/670246#M201164</guid>
      <dc:creator>shidehrafigh</dc:creator>
      <dc:date>2020-07-18T02:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate AUC in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/670298#M201190</link>
      <description>&lt;P&gt;Yes. You are right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;how can we calculate&amp;nbsp; the number of TP and FP for different cut-offs?"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Actually ROC curve is just plot by TP and FP and you can get it by ODS OUTPUT .......&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want calculated it on your own .&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; wrote a blog about it before.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here are some code to calculated TP and FP .&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;
libname x v9 'D:\工作文件\花生好车2\备份\hs_data' access=readonly;

data have;
 set x.score_card;
 keep good_bad total_score;
run;

proc sort data=have(keep=total_score) out=score nodupkey;
by descending total_score;
run;
data score;
 set score end=last;
 output;
 if last then do;total_score=total_score-1;output;end;
run;
proc sort data=score;
by total_score;
run;

proc sort data=have;
by good_bad total_score;
run;



proc delete data=want;run;
%macro roc(score=);
data temp;
 set have;
 if total_score&amp;lt;=&amp;amp;score then score_good_bad='bad ';
  else score_good_bad='good';
run;
proc sql;
create table temp1 as
 select good_bad,sum(score_good_bad='good')/count(*) as percent
  from temp
   group by good_bad;
quit;
proc transpose data=temp1 out=temp2;
id good_bad;
var percent;
run;
data temp3;
 set temp2(rename=(good=sensitity bad=_1_minus_specifity));
 score=&amp;amp;score;
 drop _name_;
run;
proc append base=want data=temp3 force;
run;
%mend;



data _null_;
 set score;
 call execute(cats('%roc(score=',total_score,')'));
run;



data roc;
 set want;
 dx=-dif(_1_minus_specifity);
 dy=mean(sensitity,lag(sensitity));
 roc=dx*dy;
run;

proc sql noprint;
select sum(roc) into : roc from roc;
quit;






proc sgplot data=want aspect=1 noautolegend;
lineparm x=0 y=0 slope=1/lineattrs=(color=grey);
series x=_1_minus_specifity y=sensitity;
inset "ROC = &amp;amp;roc"/position=topleft;
xaxis grid;
yaxis grid;
run;




/*方法二  Second Way*/
ods graphics on;
data have2;
 set have;
 retain dummy 1;
run;
proc logistic data=have2;
model good_bad(event='good')=total_score dummy/nofit;
roc 'Expert Predictions' pred=total_score;
roc 'Dummy' pred=dummy;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Jul 2020 12:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-AUC-in-this-case/m-p/670298#M201190</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-07-18T12:04:32Z</dc:date>
    </item>
  </channel>
</rss>

