<?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 Probability of default long run adjustment in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Probability-of-default-long-run-adjustment/m-p/334300#M272223</link>
    <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing the code for the long run adjustment for probability of default model and the code fails to run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you be so kind to advise the code below? thanks a lot!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data = pd.model_EJM;
%let lr_avg = 0.033825737;
%let difference = 0.000001;
%let gap = -0.07;

%macro lr;
%do %until (&amp;amp;PD_diff &amp;lt;= &amp;amp;difference);
   data base;
   set &amp;amp;data;
   alpha = -6.0736;
   beta = 7.1518*beh_pred_pd + 26.2966*fin_pred_pd + 47.0150*qual_pred_pd;
   PD = exp(sum(&amp;amp;gap,alpha,beta)) / sum(1,exp(sum(&amp;amp;gap,alpha,beta)));
   adj_factor = &amp;amp;gap;
   run;

   proc sql;
   create table abc
   as select mean(PD) as avg_PD
   from base;
   quit;

   data abc;
   set abc;
   PD_diff = sum (avg_PD, -1 *&amp;amp;lr_avg);
   run;

   proc sql noprint;
   select round(PD_diff, 0.000001) into: PD_diff
   from abc;
   quit;

   %if &amp;amp;PD_diff &amp;gt; 0 %then %do;
      proc sql noprint;
      select sum(max(adj_factor), - 0.0001) into: gap
      from base;
      quit;
   %end;
   %else %if &amp;amp;PD_diff &amp;lt; 0 %then %do;
      proc sql noprint;
      select sum(max(adj_factor), 0.0001) into: gap
      from base;
      quit;
   %end;
%end;
%mend;
%lr;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The log shows that the PD_diff is not a numerical value therefore cannot run the code....&lt;/P&gt;&lt;P&gt;is there anyway I can fix the code...&lt;/P&gt;&lt;P&gt;thanks a lot!!!&lt;/P&gt;</description>
    <pubDate>Mon, 20 Feb 2017 11:27:35 GMT</pubDate>
    <dc:creator>samwong0107</dc:creator>
    <dc:date>2017-02-20T11:27:35Z</dc:date>
    <item>
      <title>Probability of default long run adjustment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Probability-of-default-long-run-adjustment/m-p/334300#M272223</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing the code for the long run adjustment for probability of default model and the code fails to run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you be so kind to advise the code below? thanks a lot!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data = pd.model_EJM;
%let lr_avg = 0.033825737;
%let difference = 0.000001;
%let gap = -0.07;

%macro lr;
%do %until (&amp;amp;PD_diff &amp;lt;= &amp;amp;difference);
   data base;
   set &amp;amp;data;
   alpha = -6.0736;
   beta = 7.1518*beh_pred_pd + 26.2966*fin_pred_pd + 47.0150*qual_pred_pd;
   PD = exp(sum(&amp;amp;gap,alpha,beta)) / sum(1,exp(sum(&amp;amp;gap,alpha,beta)));
   adj_factor = &amp;amp;gap;
   run;

   proc sql;
   create table abc
   as select mean(PD) as avg_PD
   from base;
   quit;

   data abc;
   set abc;
   PD_diff = sum (avg_PD, -1 *&amp;amp;lr_avg);
   run;

   proc sql noprint;
   select round(PD_diff, 0.000001) into: PD_diff
   from abc;
   quit;

   %if &amp;amp;PD_diff &amp;gt; 0 %then %do;
      proc sql noprint;
      select sum(max(adj_factor), - 0.0001) into: gap
      from base;
      quit;
   %end;
   %else %if &amp;amp;PD_diff &amp;lt; 0 %then %do;
      proc sql noprint;
      select sum(max(adj_factor), 0.0001) into: gap
      from base;
      quit;
   %end;
%end;
%mend;
%lr;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The log shows that the PD_diff is not a numerical value therefore cannot run the code....&lt;/P&gt;&lt;P&gt;is there anyway I can fix the code...&lt;/P&gt;&lt;P&gt;thanks a lot!!!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2017 11:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Probability-of-default-long-run-adjustment/m-p/334300#M272223</guid>
      <dc:creator>samwong0107</dc:creator>
      <dc:date>2017-02-20T11:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Probability of default long run adjustment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Probability-of-default-long-run-adjustment/m-p/334304#M272224</link>
      <description>&lt;P&gt;Try using %evalf for the comparison since you have floating point numbers.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2017 11:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Probability-of-default-long-run-adjustment/m-p/334304#M272224</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-20T11:41:08Z</dc:date>
    </item>
  </channel>
</rss>

