BookmarkSubscribeRSS Feed
Satyakshma
Fluorite | Level 6

Hello Everyone,

 

I have to calculate the predicted values for year 2015, 2016 and 2017 for Bucket1, Bucket2, Bucket3 and Bucket4 using a Z_score and an Index value. I already have Z_Score from other table, but I need to generate an Index value (which is a random value).
The Index value to be generated should be such that that when we calculate predicted PD using it for each year. The sum square errors of Predicted PDs and Actual PDs should be minimum.

I am able to do this in Excel using Run solver function, and I need to do this using PROC FCMP in BASE SAS in SAS EG as I don't have SAS/IML or SAS/OR COMPONENT. Please help me with this code as I am new to PROC FCMP.

Attached is the Input table and desired output table:

Table 1: Using Z Score from this

 

Col1Value 1Z value
10.86%-2.38
226.02%-0.64
342.43%-0.19
464.78%0.38

 

Table 2: Bucket-wise Actual values for each year

 

Col12015201620172018
11.15%0.66%0.51%1.13%
232.38%22.38%18.04%31.26%
350.08%37.32%38.41%43.91%
469.31%59.29%57.13%73.38%
599.72%100.00%100.00%100.00%

 

Table 3: Index values are random values generated, and used in calculating predicted values in bold

 

Index value0.1000000.170699-0.133416-0.1783820.135047
Col1 2015201620172018
1 1.35%0.59%0.52%1.23%
2 31.84%21.88%20.58%30.58%
3 49.19%37.28%35.59%47.77%
4 70.88%59.71%57.96%69.65%

 

Table 4: Min sum of squares (between actual values and predicted values) value and Index value.

 

 Sum of SquaresIndex
 0.000 
20150.0000.17
20160.000-0.13
20170.002-0.18
20180.0030.14

 

Also, attached is the excel file for more clarity of data.

Looking forward for help as I am new to proc fcmp.

 

Thanks,

Satyakshma Rawat

2 REPLIES 2
Satyakshma
Fluorite | Level 6
Hi Bart,

I tried to write the PROC FCMP code using this link, but I am not able to create the code for the desired output. I am sharing the code below I have written.
PROC FCMP OUTLIB=work.functions.ci;

function predict(currentValue);
return(CDF('NORMAL', currentValue + index));
endsub;

function sum_square_error(value1,value2);
diff = (value1-value2);
return(diff*diff);
endsub;

function minimum(y,sse,index,value1,value2);
return(solve("sum_square_error",.,y,min(sse));
endsub;

QUIT;


options cmplib=( work.functions);

data test;
set test;
predicted = cred_index(Z_score);
err = sum_square_error(actual,predicted);
run;

I am currently working on this code, though I am not sure I am applying all the logic in proper way.

Thanks,
Satyakshma Rawat

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 496 views
  • 0 likes
  • 2 in conversation