<?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: Question in the DO LOOP regard to the value of X1 in the code in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Question-in-the-DO-LOOP-regard-to-the-value-of-X1-in-the-code/m-p/589893#M14956</link>
    <description>&lt;P&gt;Thank yo so much for your helpl. Got now.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2019 02:50:27 GMT</pubDate>
    <dc:creator>Jack2012</dc:creator>
    <dc:date>2019-09-19T02:50:27Z</dc:date>
    <item>
      <title>Question in the DO LOOP regard to the value of X1 in the code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-in-the-DO-LOOP-regard-to-the-value-of-X1-in-the-code/m-p/589549#M14912</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let p0=0.05;
%let p1=0.25;
%let alpha=0.1;
%let beta=0.1; 
%let usern=15;

 ****Stage 1;
  data stage1;
     do n1=5 to &amp;amp;usern-1;/*The totals ACCEPTABLE size is set sas "usern", n1 is the total size to be studied at stage 1*/
     do r1=0;
     term1_p0 = cdf('BINOMIAL', r1, &amp;amp;p0, n1);/*PET: probability of terminate after stage 1 when the drug is ineffective;This is also the Type I ERROR at stage 1*/
     term1_p1 = cdf('BINOMIAL', r1, &amp;amp;p1, n1);/*Probability of early ternation after stage 1 when, in fact, the drug is effective;*/
     if term1_p1=&amp;lt;&amp;amp;beta then output; /*remove solution sets that do not meet the beta requirement; This is the type II ERROR occurred at stage 1*/
     end;
     end;
  run;
  
  *****Stage 2; 
  data stage12; 
  	set stage1;
  	do n2=n1+1 to &amp;amp;usern-1;
  		do r2=r1+1 to n2 while (r1&amp;lt;r2&amp;lt;n2);
  			**term2_p0=0; *****initialize the summation terms for alpha &amp;amp; beta calculations;
  			**term2_p1=0;
  			do x1=r1+1 to min(r2, n1);/*x1: stand for the possible number of responses at stage 2 ONLY*/
  				**dum0=pdf('BINOMIAL', x1, &amp;amp;p0, n1)*cdf('BINOMIAL', r2-x1, &amp;amp;p0, n2-n1);
  				**dum1=pdf('BINOMIAL', x1, &amp;amp;p1, n1)*cdf('BINOMIAL', r2-x1, &amp;amp;p1, n2-n1);
  				**term2_p0= term2_p0+dum0;*recursive formulae used for summation terms;
  				**term2_p1= term2_p1+dum1;
				output;
  			end;
  			output;/*Remove the conditions "1-(term1_p0+term2_p0)=&amp;lt;&amp;amp;alpha and" */
  		end;
  	end;
  run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regard to the above code, how could the value of &lt;FONT color="#3366FF"&gt;X1 be greater than r2&lt;/FONT&gt; as shown in below shot?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="do loop question.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32553iAD4B9FE786AE5605/image-size/large?v=v2&amp;amp;px=999" role="button" title="do loop question.png" alt="do loop question.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 07:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-in-the-DO-LOOP-regard-to-the-value-of-X1-in-the-code/m-p/589549#M14912</guid>
      <dc:creator>Jack2012</dc:creator>
      <dc:date>2019-09-18T07:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Question in the DO LOOP regard to the value of X1 in the code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-in-the-DO-LOOP-regard-to-the-value-of-X1-in-the-code/m-p/589558#M14914</link>
      <description>Take a simple case:&lt;BR /&gt;&lt;BR /&gt;do v1 = 1 to 5;&lt;BR /&gt;end; &lt;BR /&gt;Output;&lt;BR /&gt;&lt;BR /&gt;The final value of v1 is 6, not 5.  Each time through the loop, SAS gets to the END statement and adds 1 to v1.  So the fifth time through v1 increases from 5 to 6.  SAS now notices that the loop is done because v1 exceeds the upper range of the loop.  &lt;BR /&gt;&lt;BR /&gt;Similarly, in your loop the loop is over when x1 exceeds min(r2,  n1) and the final OUTPUT statement outputs (below the loop) that result.</description>
      <pubDate>Wed, 18 Sep 2019 08:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-in-the-DO-LOOP-regard-to-the-value-of-X1-in-the-code/m-p/589558#M14914</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-09-18T08:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Question in the DO LOOP regard to the value of X1 in the code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-in-the-DO-LOOP-regard-to-the-value-of-X1-in-the-code/m-p/589893#M14956</link>
      <description>&lt;P&gt;Thank yo so much for your helpl. Got now.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 02:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-in-the-DO-LOOP-regard-to-the-value-of-X1-in-the-code/m-p/589893#M14956</guid>
      <dc:creator>Jack2012</dc:creator>
      <dc:date>2019-09-19T02:50:27Z</dc:date>
    </item>
  </channel>
</rss>

