<?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 We separate Odd and Even and Prime numbers in SAS ??? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627446#M185240</link>
    <description>&lt;P&gt;Through that programme i values =1 2 3 4 ..........................1000 right&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;through that dataset i want create new dataset have three new variables&lt;/P&gt;&lt;P&gt;like&lt;/P&gt;&lt;P&gt;Odd_Number ( first variable name ) = 1 3 5 7 9 11 ................999&lt;/P&gt;&lt;P&gt;Even_Number (second variable name) = 2 4 6 8 10 12 ..................1000&lt;/P&gt;&lt;P&gt;Prime_Numbers (third variable name) = 2 3 5 7 11 13 ...........997&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like these i want output...I Hope you understand my doubt what i need in output dataset..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find a solution for that !!!!&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2020 09:31:03 GMT</pubDate>
    <dc:creator>Mohan_Reddy</dc:creator>
    <dc:date>2020-02-26T09:31:03Z</dc:date>
    <item>
      <title>How We separate Odd and Even and Prime numbers in SAS ???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627444#M185238</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;I have dataset like below...

data ds;

do i=1 to 1000;

output;

end;

stop;

run;

Now i want output like

Using that dataset "i" value create 3 new columns(variables)..One Variable should contain Odd numbers and

One variable should contain Even numbers

Last variable should contain Prime numbers

How&amp;nbsp;do write a programme&amp;nbsp;???please&amp;nbsp;help&amp;nbsp;us....&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 09:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627444#M185238</guid>
      <dc:creator>Mohan_Reddy</dc:creator>
      <dc:date>2020-02-26T09:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: How We separate Odd and Even and Prime numbers in SAS ???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627445#M185239</link>
      <description>&lt;P&gt;What if a number is both prime and odd?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 09:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627445#M185239</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-26T09:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: How We separate Odd and Even and Prime numbers in SAS ???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627446#M185240</link>
      <description>&lt;P&gt;Through that programme i values =1 2 3 4 ..........................1000 right&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;through that dataset i want create new dataset have three new variables&lt;/P&gt;&lt;P&gt;like&lt;/P&gt;&lt;P&gt;Odd_Number ( first variable name ) = 1 3 5 7 9 11 ................999&lt;/P&gt;&lt;P&gt;Even_Number (second variable name) = 2 4 6 8 10 12 ..................1000&lt;/P&gt;&lt;P&gt;Prime_Numbers (third variable name) = 2 3 5 7 11 13 ...........997&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like these i want output...I Hope you understand my doubt what i need in output dataset..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find a solution for that !!!!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 09:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627446#M185240</guid>
      <dc:creator>Mohan_Reddy</dc:creator>
      <dc:date>2020-02-26T09:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: How We separate Odd and Even and Prime numbers in SAS ???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627452#M185244</link>
      <description>&lt;P&gt;Instead of creating redundant values, create flags:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let max = 1000;

data have;
do i = 1 to &amp;amp;max.;
  output;
end;
run;

data want;
set have;
length primes $&amp;amp;max.;
retain primes;
if mod(i,2) = 0
then do;
  odd = 'N';
  even = 'Y';
end;
else do;
  odd = 'Y';
  even = 'N';
end;
if substr(primes,i,1) = ' '
then prime = 'Y';
else prime = 'N';
index = i;
if i &amp;gt; 1 then do while (index &amp;lt;= &amp;amp;max.);
  substr(primes,index,1) = 'Y';
  index + i;
end;
drop primes index;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Feb 2020 10:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627452#M185244</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-26T10:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: How We separate Odd and Even and Prime numbers in SAS ???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627454#M185245</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=j);
   array p {1000} _temporary_ (0 2:1000);

   do i = 2 to 1000;              
      do j = i to 1000/i;              
         p [i*j] = 0;
      end;
   end;

   do until (lr);
      set ds end=lr;
      call missing (Even, Odd, Prime);
      if mod(i, 2) = 0 then Even = i;
      else                  Odd = i;
      if whichn(i, of p[*]) then prime = i;
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Feb 2020 10:08:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-We-separate-Odd-and-Even-and-Prime-numbers-in-SAS/m-p/627454#M185245</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-26T10:08:49Z</dc:date>
    </item>
  </channel>
</rss>

