<?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: scan a numeric macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/scan-a-numeric-macro-variable/m-p/326473#M72696</link>
    <description>&lt;P&gt;To elaborate on one point within Reeza's answer, %SCAN lets you specify blanks only as delimiters in this fashion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;coef,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1,%str( ))&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Occasionally, you will see a version that is wrong, but usually works properly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;coef,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1, ' ')&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While this does treat blanks as delimiters, it also treats quotes as delimiters. &amp;nbsp;Usually that doesn't cause any harm, but that probably was not the intention of the programmer.&lt;/P&gt;</description>
    <pubDate>Sat, 21 Jan 2017 03:38:39 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-01-21T03:38:39Z</dc:date>
    <item>
      <title>scan a numeric macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-a-numeric-macro-variable/m-p/326464#M72689</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have code like this:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; coef = -177 1 -27 -34 -26 -27 -31 -25 -54 -28 -28 -25 -36 -36 7 8 11 50 -9 10 27;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; data;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; data;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;score= &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;coef,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;)*col1 + &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;coef,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;)*col2 + &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;coef,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;)*col3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calc &lt;STRONG&gt;score= -117*col1 + 1*col2 + (-27)*col3;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;but i realize that %scan ignored the negative signs, so what i actually got is &lt;STRONG&gt;score= 117*col1 + 1*col2 + (27)*col3&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me resolve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best wishes.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jan 2017 02:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-a-numeric-macro-variable/m-p/326464#M72689</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2017-01-21T02:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: scan a numeric macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-a-numeric-macro-variable/m-p/326467#M72692</link>
      <description>&lt;P&gt;A better method, use a temporary array to store the elements and then a loop.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have not specified a separator for your terms in the SCAN function. Specify the delimiter/separator. When you create the macro variable list you can specify the delimiter of choice.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, is there a reason for using %scan instead of scan?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jan 2017 03:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-a-numeric-macro-variable/m-p/326467#M72692</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-21T03:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: scan a numeric macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-a-numeric-macro-variable/m-p/326473#M72696</link>
      <description>&lt;P&gt;To elaborate on one point within Reeza's answer, %SCAN lets you specify blanks only as delimiters in this fashion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;coef,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1,%str( ))&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Occasionally, you will see a version that is wrong, but usually works properly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;coef,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1, ' ')&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While this does treat blanks as delimiters, it also treats quotes as delimiters. &amp;nbsp;Usually that doesn't cause any harm, but that probably was not the intention of the programmer.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jan 2017 03:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-a-numeric-macro-variable/m-p/326473#M72696</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-21T03:38:39Z</dc:date>
    </item>
  </channel>
</rss>

