<?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: How to write code for this iteration in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-code-for-this-iteration/m-p/646845#M193539</link>
    <description>&lt;P&gt;I guess you mean:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do dummy = 1 to 1000 while(ABS(TCC-cut) &amp;gt; delta);
	If TCC - cut &amp;gt; delta then theta = theta-ABS(theta-low)/2;
	if TCC - cut &amp;lt; -delta then theta = theta+ABS(hi-theta)/2;
	end;
prob=exp(theta-bpar)/(1+exp(theta-bpar));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The dummy count was added to prevent infinite looping.&lt;/P&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
    <pubDate>Mon, 11 May 2020 18:30:50 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-05-11T18:30:50Z</dc:date>
    <item>
      <title>How to write code for this iteration</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-code-for-this-iteration/m-p/646786#M193516</link>
      <description>&lt;P&gt;My data is as attached.&lt;/P&gt;
&lt;P&gt;prob is get by the following formula&lt;/P&gt;
&lt;P&gt;prob=exp(theta-bpar)/(1+exp(theta-bpar))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I need to update theta (then update prob)&lt;/STRONG&gt; using the following condition&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If TCC - cut &amp;gt; delta then theta=theta-ABS(theta-low)/2&lt;/P&gt;
&lt;P&gt;if TCC - cut &amp;lt; (-1*delta) then theta=theta+ABS(hi-theta)/2&lt;/P&gt;
&lt;P&gt;iteration will stop&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if ABS(TCC-cut)&amp;lt;=delta&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help on how to write code to incorporate the above conditions to do the iteration. Any help would be much appreciated. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 16:03:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-code-for-this-iteration/m-p/646786#M193516</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-05-11T16:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to write code for this iteration</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-code-for-this-iteration/m-p/646845#M193539</link>
      <description>&lt;P&gt;I guess you mean:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do dummy = 1 to 1000 while(ABS(TCC-cut) &amp;gt; delta);
	If TCC - cut &amp;gt; delta then theta = theta-ABS(theta-low)/2;
	if TCC - cut &amp;lt; -delta then theta = theta+ABS(hi-theta)/2;
	end;
prob=exp(theta-bpar)/(1+exp(theta-bpar));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The dummy count was added to prevent infinite looping.&lt;/P&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 18:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-code-for-this-iteration/m-p/646845#M193539</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-05-11T18:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to write code for this iteration</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-code-for-this-iteration/m-p/647117#M193626</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks much for your reply!&lt;/P&gt;
&lt;P&gt;I need to write SAS code based on the following code. From the code below, does that mean Newton Raphson iteration is needed? If yes, could you please direct me how to do that? FIY, "try" in the code below is the "try.csv" as in the attachment. Thanks a bunch!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LOOP K = 1 TO 150.&lt;/P&gt;
&lt;P&gt;COMPUTE theta_lo={-20}.&lt;BR /&gt;COMPUTE theta_hi={20}.&lt;BR /&gt;COMPUTE delta={.000001}.&lt;BR /&gt;COMPUTE cut={K}.&lt;BR /&gt;COMPUTE theta={0}.&lt;BR /&gt;COMPUTE low={theta_lo}.&lt;BR /&gt;COMPUTE hi={theta_hi}.&lt;BR /&gt;COMPUTE IPROB=MAKE(NITEM,1,0).&lt;BR /&gt;COMPUTE IINFO=MAKE(NITEM,1,0).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;LOOP.&lt;/P&gt;
&lt;P&gt;LOOP J=1 TO NITEM.&lt;BR /&gt;COMPUTE IPROB(J)=(exp(theta-try(J,2))/(1+exp(theta-try(J,2))))).&lt;BR /&gt;COMPUTE IINFO(J)=IPROB(J)*(1-IPROB(J)).&lt;BR /&gt;END LOOP.&lt;BR /&gt;COMPUTE TCC=CSUM(IPROB).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;DO IF (tcc-cut&amp;gt;delta).&lt;BR /&gt;COMPUTE hi = theta.&lt;BR /&gt;COMPUTE theta=theta-ABS((theta-low))/2.&lt;BR /&gt;END IF.&lt;BR /&gt;DO IF (tcc-cut&amp;lt; (-1*delta)).&lt;BR /&gt;COMPUTE low=theta.&lt;BR /&gt;COMPUTE theta=theta+ABS((hi-theta))/2.&lt;BR /&gt;END IF.&lt;BR /&gt;&lt;BR /&gt;END LOOP IF (abs(tcc-cut)&amp;lt;=delta).&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 15:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-code-for-this-iteration/m-p/647117#M193626</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-05-12T15:00:18Z</dc:date>
    </item>
  </channel>
</rss>

