<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: MLE using a data step within PROC IML in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890352#M6038</link>
    <description>&lt;P&gt;Thank you, Rick and Tom.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see that symget works in the ml environment. However, in the line highlighted by Tom "C = &amp;amp;total_ll.;", the macro variable is not getting updated with each iteration of nlpnra. It simply retains the value before the start of proc iml.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions on how do I update this variable with nlpnra?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Aug 2023 10:35:13 GMT</pubDate>
    <dc:creator>rakeshallu</dc:creator>
    <dc:date>2023-08-22T10:35:13Z</dc:date>
    <item>
      <title>MLE using a data step within PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890311#M6033</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies for the multiple posts. I wanted to share the progress I was able to make with the previous question. In case it helps anyone help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used 'submit' and 'endsubmit' to convert all the vector operations in my previous post into data steps. This enabled me to get rid of the Do-loop. However, with the code below, nlpnra is simply returning the initial value.&amp;nbsp; Any suggestions on what am I doing wrong will be very helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc iml;
start LogLik(param);
p1 = param[1]; 
p2 = param[2]; 
p3 = param[3]; 
p4 = param[4]; 
p5 = param[5]; 

submit p1 p2 p3 p4 p5;

data _null_; 
	set want;
	/*scroll further probability*/
	if position &amp;lt; 3 then sc_p = 1; 
	else sc_p = logistic(&amp;amp;p1 + &amp;amp;p2*position + &amp;amp;p3*pred_usage + &amp;amp;p4*relevant_offer_cnt_wt + &amp;amp;p5*credits_r);  

	/*end probability*/ 
	if position &amp;lt; max_pos then ed = 0; 
	else ed = 1 - sc_p; 
	
	by seq; 
	retain prod_choice; 
	retain prod_scroll;
	retain ll; 
	retain total_ll 0;

	if first.seq then do; 
	prod_choice = 1; 
	prod_scroll = 1; end; 

	prod_choice = prod_choice*not_choosing_prob; 
	prod_scroll = prod_scroll*sc_p; 
	prod_choice_end = prod_choice*ed;

	lag_prod_scroll = lag(prod_scroll); 
	if first.seq then lag_prod_scroll = 1; 

	pos_end_ll = lag_prod_scroll*prod_choice_end; 

	if first.seq then ll = pos_end_ll; 
	else ll = ll + pos_end_ll; 
	if last.seq then do; 
	log_ll = log(ll);
	total_ll = total_ll + log_ll; 
	end;
call symput ("total_ll",total_ll);  
run; 
endsubmit;
C = &amp;amp;total_ll.;
return sum(C); 
finish;
param = {-0.1 -0.005 0.1 -0.1 0.2 0.0};
optn = {1, /* 3. find max of function, and */ 4}; /* print moderate amount of output */
con = {. . . . . ., 
	    . . . . . .};
call nlpnra(rc, xres, "LogLik", param, optn, con);
quit; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Best,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rakesh&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 22:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890311#M6033</guid>
      <dc:creator>rakeshallu</dc:creator>
      <dc:date>2023-08-21T22:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: MLE using a data step within PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890312#M6034</link>
      <description>&lt;P&gt;You can't have a data step within PROC IML.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 22:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890312#M6034</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-21T22:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: MLE using a data step within PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890313#M6035</link>
      <description>Thank you for the response.&lt;BR /&gt;We can do a data step within proc iml..&lt;BR /&gt;See Rick's video below -&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2011/10/24/video-calling-sas-procedures-from-the-sasiml-language.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2011/10/24/video-calling-sas-procedures-from-the-sasiml-language.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Get Outlook for Android&amp;lt;&amp;gt;</description>
      <pubDate>Mon, 21 Aug 2023 23:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890313#M6035</guid>
      <dc:creator>rakeshallu</dc:creator>
      <dc:date>2023-08-21T23:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: MLE using a data step within PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890318#M6036</link>
      <description>&lt;P&gt;Are you sure this line is getting the value of the macro variable generated by the submitted data step?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;C = &amp;amp;total_ll.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or does it just get the value of the macro variable that was present when the IML step started?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does IML have something similar to the SYMGET() or SYMGETN() function of the data step?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 01:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890318#M6036</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-22T01:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: MLE using a data step within PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890351#M6037</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;Does IML have something similar to the SYMGET() or SYMGETN() function of the data step?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;You can call almost every DATA step function from an IML program. See&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2010/09/08/calling-base-sas-functions-from-sasiml-programs.html" target="_blank" rel="noopener"&gt;Calling Base SAS Functions from SAS/IML Programs - The DO Loop&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Specifically, you can certainly call SYMGET.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both SYMGET and directly referencing the macro variable will work. For example, run this program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;

SUBMIT;
data _null_;
  call symputx("test", 3.14);
run;
ENDSUBMIT;

x = &amp;amp;test;
y = symget("test");
print x y;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;However, if you are using a DO loop, then use SYMGET, because the loop is parsed and compiled, which means that the macro resolution occurs at parse time, not run time. See&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2013/06/19/macros-and-loops.html" target="_blank"&gt;Macros and loops in the SAS/IML language - The DO Loop&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 10:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890351#M6037</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-08-22T10:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: MLE using a data step within PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890352#M6038</link>
      <description>&lt;P&gt;Thank you, Rick and Tom.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see that symget works in the ml environment. However, in the line highlighted by Tom "C = &amp;amp;total_ll.;", the macro variable is not getting updated with each iteration of nlpnra. It simply retains the value before the start of proc iml.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions on how do I update this variable with nlpnra?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 10:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890352#M6038</guid>
      <dc:creator>rakeshallu</dc:creator>
      <dc:date>2023-08-22T10:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: MLE using a data step within PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890353#M6039</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;Apologies for the multiple posts.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;DIV class="sas-author-username"&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446374"&gt;@rakeshallu&lt;/a&gt;&amp;nbsp;I was going to look at your issue, but now I don't know which one is active.&lt;/DIV&gt;
&lt;DIV class="sas-author-username"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sas-author-username"&gt;Regarding your attempt to use the SUBMIT block inside an objective function to a nonlinear optimization, I would discourage this approach. It will be harder to develop, debug, and understand this hybrid approach. Furthermore, the objective function needs to be fast because it will be called potentially hundreds of times during the optimization. There is considerable overhead costs to using the SUBMIT block, so I suspect that the performance will be better by using a native SAS IML function module as the objective function.&lt;/DIV&gt;</description>
      <pubDate>Tue, 22 Aug 2023 10:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890353#M6039</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-08-22T10:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: MLE using a data step within PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890357#M6040</link>
      <description>&lt;P&gt;Thank you, Rick. In light of this suggestion, we could put the submit/endsubmit thread to rest.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the previous post, I use the native SAS IML module to compute the objective function. Any suggestions on improving it would be very helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 10:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/MLE-using-a-data-step-within-PROC-IML/m-p/890357#M6040</guid>
      <dc:creator>rakeshallu</dc:creator>
      <dc:date>2023-08-22T10:45:18Z</dc:date>
    </item>
  </channel>
</rss>

