<?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: do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/253387#M48208</link>
    <description>&lt;P&gt;I looked at the picture of your data and wrote this. &amp;nbsp;Perhaps with this and if you provide and explanation&amp;nbsp;of what you need someone will be able to help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data col;
   infile cards missover;
   input id:$3. (col1-col3)(:$2.);
   cards;
001 TP
002 TP 
003 RP
004 TP
005 TP
006 RP TP
007 RP
008 RP TP
009 RP
010 RP
011 TP RP RP
;;;;
   run;
proc print;
   run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2100i30E5273BE93C5981/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2016 11:08:46 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2016-03-01T11:08:46Z</dc:date>
    <item>
      <title>do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/253348#M48196</link>
      <description>&lt;P&gt;I would like to do infinity loop like in JAVA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for(i=1;i&amp;lt;200;I++){&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (COL(i) != COL1 AND COL(i) != " &amp;nbsp;") {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q_person_type = "Multiple";&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q_person_type = COL1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For SAS Code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test3(keep=q_full_nm q_person_type rename=(q_full_nm=node_tooltip));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; set test2;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; do i = 1 to n by 1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q_person_type=COL1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if COLi ne ' ' AND COLi ne COL1 then q_person_type="Multiple";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot run this code, could you please check it which part i'm wrong&lt;/P&gt;&lt;P&gt;what i want is if COL2, COL3 ... until COL N is not equal to COL1 return "Multiple" but if COL2, COL3 .... until COL N is equal to COL1 or is " &amp;nbsp;" return COL1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see picture for more understanding&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12329i884E4CF156F2876D/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="pic.JPG" title="pic.JPG" /&gt;</description>
      <pubDate>Tue, 01 Mar 2016 05:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/253348#M48196</guid>
      <dc:creator>Mayohnim</dc:creator>
      <dc:date>2016-03-01T05:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/253355#M48198</link>
      <description>You need to fill an array with your col2 to coln variables, and loop over that.</description>
      <pubDate>Tue, 01 Mar 2016 07:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/253355#M48198</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-03-01T07:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/253371#M48204</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use arrays to loop over data, example below. &amp;nbsp;Please note this code is not tested. &amp;nbsp;If you want working code, please post test data - in the form of a datastep, which reflects your actual data - and what you want the output to look like.&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  array col{3};
  result="Pass";
  do i=2 to 3;
    if col{i} ne col{1} then result="Fail";
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Mar 2016 09:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/253371#M48204</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-01T09:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/253387#M48208</link>
      <description>&lt;P&gt;I looked at the picture of your data and wrote this. &amp;nbsp;Perhaps with this and if you provide and explanation&amp;nbsp;of what you need someone will be able to help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data col;
   infile cards missover;
   input id:$3. (col1-col3)(:$2.);
   cards;
001 TP
002 TP 
003 RP
004 TP
005 TP
006 RP TP
007 RP
008 RP TP
009 RP
010 RP
011 TP RP RP
;;;;
   run;
proc print;
   run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2100i30E5273BE93C5981/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 11:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop/m-p/253387#M48208</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-03-01T11:08:46Z</dc:date>
    </item>
  </channel>
</rss>

