BookmarkSubscribeRSS Feed
samwong0107
Calcite | Level 5

Hi all

 

I am writing the code for the long run adjustment for probability of default model and the code fails to run.

 

Would you be so kind to advise the code below? thanks a lot!!

 

%let data = pd.model_EJM;
%let lr_avg = 0.033825737;
%let difference = 0.000001;
%let gap = -0.07;

%macro lr;
%do %until (&PD_diff <= &difference);
   data base;
   set &data;
   alpha = -6.0736;
   beta = 7.1518*beh_pred_pd + 26.2966*fin_pred_pd + 47.0150*qual_pred_pd;
   PD = exp(sum(&gap,alpha,beta)) / sum(1,exp(sum(&gap,alpha,beta)));
   adj_factor = &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 *&lr_avg);
   run;

   proc sql noprint;
   select round(PD_diff, 0.000001) into: PD_diff
   from abc;
   quit;

   %if &PD_diff > 0 %then %do;
      proc sql noprint;
      select sum(max(adj_factor), - 0.0001) into: gap
      from base;
      quit;
   %end;
   %else %if &PD_diff < 0 %then %do;
      proc sql noprint;
      select sum(max(adj_factor), 0.0001) into: gap
      from base;
      quit;
   %end;
%end;
%mend;
%lr;

The log shows that the PD_diff is not a numerical value therefore cannot run the code....

is there anyway I can fix the code...

thanks a lot!!!

1 REPLY 1
Reeza
Super User

Try using %evalf for the comparison since you have floating point numbers. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 338 views
  • 0 likes
  • 2 in conversation