<?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: using _n_ in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311270#M67231</link>
    <description>&lt;P&gt;Or did you have something else in mind regarding your header "Using _N_" ?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 13 Nov 2016 19:17:18 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2016-11-13T19:17:18Z</dc:date>
    <item>
      <title>using _n_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311258#M67220</link>
      <description>&lt;P&gt;I have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;STRONG&gt;data&lt;/STRONG&gt; even_odd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input x @@;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; 257779&amp;nbsp; 269998&amp;nbsp; 11&amp;nbsp; 20&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Modify the following data step to create a new variable named as message. The values of the&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable message must be:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ‘The integer is odd’ if the variable x in the input statement has odd integer, ‘The integer is even’&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if the variable x has even integer.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Should not use &amp;nbsp;mod function&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2016 17:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311258#M67220</guid>
      <dc:creator>venkatnaveen</dc:creator>
      <dc:date>2016-11-13T17:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: using _n_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311265#M67227</link>
      <description>&lt;P&gt;o what is your question?&lt;/P&gt;
&lt;P&gt;What have you tried?&lt;/P&gt;
&lt;P&gt;Explore the other truncation functions...&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2016 17:30:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311265#M67227</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-11-13T17:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: using _n_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311267#M67229</link>
      <description>question isi have variable x&lt;BR /&gt;23&lt;BR /&gt;456&lt;BR /&gt;78889&lt;BR /&gt;23 is odd  a new variable message to be creted as odd .Similarlly&lt;BR /&gt;456 is even message has to be created even</description>
      <pubDate>Sun, 13 Nov 2016 17:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311267#M67229</guid>
      <dc:creator>venkatnaveen</dc:creator>
      <dc:date>2016-11-13T17:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: using _n_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311269#M67230</link>
      <description>&lt;P&gt;The most elegant way would be to use the MOD function, but since you rule this out, this is a possibility:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data even_odd;
   input x @@;
   datalines;
   257779 269998 1120
   ;
run;

data want(keep = x evenodd);
   set even_odd;
   y = put(x, 10.);
   
   lastdigit = substr(y,length(y),-1);

   if lastdigit in ('0', '2', '4', '6', '8') then evenodd = 'Even';
   else evenodd = 'Odd';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Nov 2016 18:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311269#M67230</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2016-11-13T18:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: using _n_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311270#M67231</link>
      <description>&lt;P&gt;Or did you have something else in mind regarding your header "Using _N_" ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2016 19:17:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311270#M67231</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2016-11-13T19:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: using _n_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311279#M67235</link>
      <description>&lt;P&gt;If not using MOD function then you can check the right most digit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;string = left(x); /* convert x from numeric to characters */&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;digit = input(substr(string, length(string),1),1.);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if digit in ( 0 2 4 6 &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; then evn_odd = &amp;lt;even_message&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;else even_odd = &amp;lt;odd_message&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;enter the full text instead&amp;nbsp;&lt;STRONG&gt;&amp;lt;even_message&amp;gt; or&amp;nbsp;&amp;lt;odd_message&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2016 20:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311279#M67235</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-13T20:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: using _n_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311282#M67236</link>
      <description>&lt;P&gt;Like so often there are multiple ways to get it done.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value even_odd
    0='The integer is odd' 
    1='The integer is even'
  ;
quit;

data even_odd;
  input x @@;
  format even_odd even_odd.;
  even_odd= (int(x/2)=x/2);
  datalines;
   257779  269998  11  20
   ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Nov 2016 21:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311282#M67236</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-13T21:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: using _n_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311314#M67248</link>
      <description>&lt;P&gt;Thanks sir&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2016 03:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311314#M67248</guid>
      <dc:creator>venkatnaveen</dc:creator>
      <dc:date>2016-11-14T03:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: using _n_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311316#M67250</link>
      <description>&lt;PRE&gt;
Interesting question.


  data even_odd;
   input x @@;
   y=x-int(x/10)*10;
   if y in (0 2 4 6 8) then msg='Even';
    else msg='Odd ';
   datalines;
   257779  269998  11  20
   ;
   run;



&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Nov 2016 03:59:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-n/m-p/311316#M67250</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-11-14T03:59:47Z</dc:date>
    </item>
  </channel>
</rss>

