Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 04-26-2018 10:15 AM
(909 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

Multiple Linear Regression in SAS

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.