BookmarkSubscribeRSS Feed
asifgeneral
Calcite | Level 5

 

Hello,

 

My below mentioned code runs into an error:

 

%macro BaselCap(PD, LGD, EAD, corr);
temp1=((1/1-&corr))**0.5)*probit(&PD)+ ((&corr/1-&Corr))**0.5)*probit(0.999));
temp2=CDF('Normal',temp1);
Cap=&EAD*&LGD*(temp2-&PD);
%mend BaselCap;

 

data resmortgage;
do i=1 to 999;
PD=i/1000;
%BaselCap(PD, LGD=0.50, EAD=1, corr=0.15);
output;
end;
run;

 

Can you please assist, Thanks

4 REPLIES 4
pau13rown
Lapis Lazuli | Level 10

the problem is likely with this bit of code:

PD=i/1000;
%BaselCap(PD, LGD=0.50, EAD=1, corr=0.15);

 

make pd a macro variable

%BaselCap(PD=&pd, LGD=0.50, EAD=1, corr=0.15);

Astounding
PROC Star

You have a mismatch between how you define the macro and how you use it.  

 

For this definition:

 

%macro BaselCap(PD, LGD, EAD, corr);

 

you would need to call it in this way:

 

%BaselCap(pd, 0.50, 1, 0.15)

 

If you define it using equal signs instead:

 

%macro BaselCap(PD=, LGD=, EAD=, corr=);

 

then you would need to call it with equal signs:

 

%BaselCap(PD=pd, LGD=0.50, EAD=1, corr=0.15)

 

Note that adding a semicolon at the end of a macro usually won't hurt anything, but isn't necessary.

Patrick
Opal | Level 21

@asifgeneral

You've got your brackets "messed-up" and though the function encounters a closing bracket without a related opening bracket so at this place only an operator would be allowed..

Capture.JPG

 

 

Sorting out the brackets "mess" and things work.

I'm of course not sure if I've set the brackets in below code as you need it logically.

%macro BaselCap(PD, LGD, EAD, corr);
  temp1=( (1/(1-&corr))**0.5 *probit(&PD)+ ((&corr/1-&Corr))**0.5 *probit(0.999));
  temp2=CDF('Normal',temp1);
  Cap=&EAD*&LGD*(temp2-&PD);
%mend BaselCap;

 

asifgeneral1
Calcite | Level 5
thank you Patrick

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
  • 4 replies
  • 2295 views
  • 2 likes
  • 5 in conversation