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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

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

Posted 03-30-2016 05:20 AM
(1004 views)

Hi, I want to route the log generated by SAS IML to an external file. I have a loop to execute and I want to route the log of each loop to a different file. I have used proc printto procedure in combination with submit and endsubmit statement to execute the procedure inside SAS IML. However the result I got is empty log file.

The code looks like this:

proc iml;

do i=1 to 7;

submit i;

proc printto log="D:\SAS generated files\log &i.log" new;

run;

endsubmit;

end;

quit;

1 ACCEPTED SOLUTION

Accepted Solutions

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

OK. I assume that you are using a built-in NLP routine (such as NLPNRA) to compute each optimization. The first argument to an NLP function is a return code (rc). So your call looks like this:

call nlpnra(rc, result, "ObjectiveFunc", InitGuess, options);

When the function returns, the value of the return code will be positive if the optimization converged and negative if the optimization did not converge. Therefore you can save the value of each return code and examine them later, together with the initial guess. Here's some pseudocode to get you started:

```
proc iml;
...
convergence = j(100,1,.);
initialGuess = j(100, numParams);
do i = 1 to 100;
/* set i_th guess from file or randomly or systematically */
initGuess = T( randfun(NumParams, "Normal") );
call nlpnra(rc, result, "ObjectiveFunc", InitGuess, options);
/* save the initial guess and the return code */
convergence[i] = rc;
initialGuess[i,] = initGuess;
end;
/* now analyze relationship between convergence and initial guess */
```

You might be interested in reading this article about how to choose a good starting guess for an optimization.

3 REPLIES 3

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

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

Hi Rick. I have a long time series of bond price and I am trying to compute

the yield to maturity by mininizing the distance between the discounted

coupon value and par value and the quoted dirty bond price. Therefore I

need to do a lot of optimisation for each bond price. Some of the

optimisation cannot converge probably because I cannot manually try

different starting values; There are too many bond prices. I want to

analyze the log file each time I try a different starting value for the

entire series to see which starting value generate the least amount of no

convergence.

##- Please type your reply above this line. Simple formatting, no

attachments. -##

the yield to maturity by mininizing the distance between the discounted

coupon value and par value and the quoted dirty bond price. Therefore I

need to do a lot of optimisation for each bond price. Some of the

optimisation cannot converge probably because I cannot manually try

different starting values; There are too many bond prices. I want to

analyze the log file each time I try a different starting value for the

entire series to see which starting value generate the least amount of no

convergence.

##- Please type your reply above this line. Simple formatting, no

attachments. -##

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

OK. I assume that you are using a built-in NLP routine (such as NLPNRA) to compute each optimization. The first argument to an NLP function is a return code (rc). So your call looks like this:

call nlpnra(rc, result, "ObjectiveFunc", InitGuess, options);

When the function returns, the value of the return code will be positive if the optimization converged and negative if the optimization did not converge. Therefore you can save the value of each return code and examine them later, together with the initial guess. Here's some pseudocode to get you started:

```
proc iml;
...
convergence = j(100,1,.);
initialGuess = j(100, numParams);
do i = 1 to 100;
/* set i_th guess from file or randomly or systematically */
initGuess = T( randfun(NumParams, "Normal") );
call nlpnra(rc, result, "ObjectiveFunc", InitGuess, options);
/* save the initial guess and the return code */
convergence[i] = rc;
initialGuess[i,] = initGuess;
end;
/* now analyze relationship between convergence and initial guess */
```

You might be interested in reading this article about how to choose a good starting guess for an optimization.

**Don't miss out on SAS Innovate - Register now for the FREE Livestream!**

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

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.