<?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 while condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-while-condition/m-p/682574#M206612</link>
    <description>&lt;P&gt;The code you posted is just going to create a new variable named N with the same value on every observation, so the output will look nothing like what you say you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you describe in words what you want as the output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like you just want to use one of these data steps instead, none of which need DO WHILE or DO UNTIL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set sashelp.class;
  if _n_&amp;lt;= 5;
run;

data want;
  set sashelp.class;
  if _n_&amp;gt;5 then stop;
run;

data want;
  set sashelp.class (obs=5);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Sep 2020 11:33:55 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-09-09T11:33:55Z</dc:date>
    <item>
      <title>do while condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-while-condition/m-p/682570#M206610</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn2;
set sashelp.class;
n=1;
do while (n&amp;lt;5);
 n+1;	
end;output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i want below output using do while and do until loops&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Name Sex Age Height Weight &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Alfred&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&lt;TD&gt;69.0&lt;/TD&gt;&lt;TD&gt;112.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Alice&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;TD&gt;56.5&lt;/TD&gt;&lt;TD&gt;84.0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Barbara&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;TD&gt;65.3&lt;/TD&gt;&lt;TD&gt;98.0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Carol&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&lt;TD&gt;62.8&lt;/TD&gt;&lt;TD&gt;102.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Henry&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&lt;TD&gt;63.5&lt;/TD&gt;&lt;TD&gt;102.5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 09 Sep 2020 11:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-while-condition/m-p/682570#M206610</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2020-09-09T11:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: do while condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-while-condition/m-p/682574#M206612</link>
      <description>&lt;P&gt;The code you posted is just going to create a new variable named N with the same value on every observation, so the output will look nothing like what you say you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you describe in words what you want as the output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like you just want to use one of these data steps instead, none of which need DO WHILE or DO UNTIL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set sashelp.class;
  if _n_&amp;lt;= 5;
run;

data want;
  set sashelp.class;
  if _n_&amp;gt;5 then stop;
run;

data want;
  set sashelp.class (obs=5);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 11:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-while-condition/m-p/682574#M206612</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-09T11:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: do while condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-while-condition/m-p/682575#M206613</link>
      <description>&lt;P&gt;Generally, DO WHILE is not for selecting rows, or iterating over rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn2;
set sashelp.class(obs=5);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn2;
     set sashelp.class;
     if _n_&amp;lt;=5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 11:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-while-condition/m-p/682575#M206613</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-09T11:33:09Z</dc:date>
    </item>
  </channel>
</rss>

