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
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.
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.
I don't know what GRETL is or what you are trying to accomplish.
Maybe these will help you get started:
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.