BookmarkSubscribeRSS Feed
jorgesribeiro
Calcite | Level 5

I need to translate this loop done in the software GRETL to SAS

 

loop foreach s PD1 PD2 PD3 PD4 PD5 PD6 PD7 PD8 PD9 -- quiet                      # 1st loop over the different scenarios loop foreach j PD_base PD_up PD_down --quiet # 2nd loop over the rating classes scalar $j_ttc = mean($j) # TTC PDs at rating-level series $j_bayes_$s = $s / ( $s + (1-$s) * (1-$j_ttc)/$j_ttc * PD_ttc/(1-PD_ttc) )                                                 # Bayesian formula scalar $j_bayes_$s[T_pd] = $j[T_pd] # Rq: starting date = T_pd endloop endloop

 

BY the end I will have 27 varaibles: ( PD1 PD2 PD3 PD4 PD5 PD6 PD7 PD8 PD9 ) * (PD_base PD_up PD_down ) 9 PDS * 3 scenarios (PD_base PD_up PD_down) PD1_bayes_PD_base PD2_bayes_PD_base PD3_bayes_PD_base PD4_bayes_PD_base PD5_bayes_PD_base PD6_bayes_PD_base PD7_bayes_PD_base PD8_bayes_PD_base PD9_bayes_PD_base PD1_bayes_PD_up PD2_bayes_PD_up PD3_bayes_PD_up PD4_bayes_PD_up PD5_bayes_PD_up PD6_bayes_PD_up PD7_bayes_PD_up PD8_bayes_PD_up PD9_bayes_PD_up PD1_bayes_PD_down PD2_bayes_PD_down PD3_bayes_PD_down PD4_bayes_PD_down PD5_bayes_PD_down PD6_bayes_PD_down PD7_bayes_PD_down PD8_bayes_PD_down PD9_bayes_PD_down PD1_bayes_PD_final PD2_bayes_PD_final PD3_bayes_PD_final PD4_bayes_PD_final PD5_bayes_PD_final PD6_bayes_PD_final PD7_bayes_PD_final PD8_bayes_PD_final PD9_bayes_PD_final Any help should be great. Thanks

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Much of this is not defined enough for us to help.

 

PD_base PD_up PD_down (what are these? how do they relate to PD1 through PD9)

rating classes not defined

scalar $j_ttc not defined

PD_ttc not defined (how do these relate to the other PD numbers??)

 

Also, we probably aren't go to do the work for you. You need to take a crack at actually creating code to do this, and if you get stuck, we ought to be able to help at that point.

--
Paige Miller
jorgesribeiro
Calcite | Level 5

The loop is working as a Macro replacing PD1 TO PD9 and permuting the other 3 variables.

and PD_ttc =0.521 it is a constant 

Thanks

 

Jorge

 

PaigeMiller
Diamond | Level 26

The loop is working as a Macro replacing PD1 TO PD9 and permuting the other 3 variables.

 

And "permuting the other 3 values" is not well defined either.


Really, there needs to be a lot more explanation and example given before we could begin to help you. Or better yet, you try to create such a loop and then if you get stuck, we ought to be able to figure out what the problem is and how to fix it.

--
Paige Miller
Rick_SAS
SAS Super FREQ

I don't know what GRETL is or what you are trying to accomplish. 

Maybe these will help you get started:

Overview of loops in SAS and SAS/IML

How to use the EXPANDGRID function to generate Cartesian products of values

jorgesribeiro
Calcite | Level 5

What I need it si not a Do loop, 

 

But I do loop that LOOPS using the name of the variables to be permutaded

 

Thanks 

JOrge

 

Rick_SAS
SAS Super FREQ

I am sure we can help you if you provide a simple example that starts with what you have and explains what you want. Usually, three or four values is sufficient.