<?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: Convert to MACRO in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329484#M271791</link>
    <description>&lt;P&gt;For a macro language loop, you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; %SUBSTR(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New"&gt;&amp;amp;UPDATE_MONTH&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;)&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Feb 2017 15:54:48 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-02-02T15:54:48Z</dc:date>
    <item>
      <title>Convert to MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329478#M271789</link>
      <description>&lt;P&gt;I have a simple code below.&amp;nbsp; The data step works fine but when I try to put the do loop inside of the MACRO I get an error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help getting the MACRO to work is appreciated.&amp;nbsp; Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; UPDATE_MONTH = 201612;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="1"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="1"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; INPUT(SUBSTR(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="1"&gt;"&amp;amp;UPDATE_MONTH"&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;), &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;2.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;); &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;PUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; i; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="1"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="1"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; &lt;STRONG&gt;&lt;I&gt;TEST&lt;/I&gt;&lt;/STRONG&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; INPUT(SUBSTR(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="1"&gt;"&amp;amp;UPDATE_MONTH"&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;),&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;), &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;2.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;); &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%PUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; i; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="1"&gt;%MEND&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;; %&lt;STRONG&gt;&lt;I&gt;TEST&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 15:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329478#M271789</guid>
      <dc:creator>GeorgeBonanza</dc:creator>
      <dc:date>2017-02-02T15:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Convert to MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329482#M271790</link>
      <description>&lt;P&gt;The Input/SUBSTR part won't work. To use functions in a macro you need to wrap them in %SYSFUNC so the macro processor can differentiate text from functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 15:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329482#M271790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-02T15:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Convert to MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329484#M271791</link>
      <description>&lt;P&gt;For a macro language loop, you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; %SUBSTR(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New"&gt;&amp;amp;UPDATE_MONTH&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;)&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 15:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329484#M271791</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-02T15:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Convert to MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329485#M271792</link>
      <description>&lt;P&gt;You may find the examples here useful&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 16:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329485#M271792</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-02T16:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Convert to MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329497#M271793</link>
      <description>&lt;P&gt;if I am understanding you correctly, then the following should work, correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="1"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; &lt;STRONG&gt;&lt;I&gt;TEST&lt;/I&gt;&lt;/STRONG&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%to&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%SYSFUNC&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;(INPUT(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%SUBSTR&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;(&amp;amp;UPDATE_MONTH,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;), &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;2.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;)); &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%PUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; i; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="1"&gt;%MEND&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;; %&lt;STRONG&gt;&lt;I&gt;TEST&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I receive the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: The INPUT function referenced in the %SYSFUNC or %QSYSFUNC macro function is not found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 16:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329497#M271793</guid>
      <dc:creator>GeorgeBonanza</dc:creator>
      <dc:date>2017-02-02T16:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Convert to MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329500#M271794</link>
      <description>&lt;P&gt;The macro processor is primarily a text based system. If you pull numeric characters from a string as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;suggest then the macro processor "sees" i = 1 to 12 (or what ever those 2 characters may be).&lt;/P&gt;
&lt;P&gt;You really only need to force "numeric" when you need the processor to see the numeric equivalen of a resolved value such as addition&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do i = 1 %to (4 + 5)&amp;nbsp;&amp;nbsp; will fail because "( " is not something that resolves to a numeric value&lt;/P&gt;
&lt;P&gt;%do 1 = 1 %to %eval(4 + 5)&amp;nbsp; works because the %eval does the integer arithmetic and yields a "9" to the processor. Sometimes you may want the %sysevalf or&amp;nbsp;to do non-integer results but I find that using that is often an idicator I am about to do something that is best not done in the macro processor.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 16:36:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329500#M271794</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-02T16:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Convert to MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329503#M271795</link>
      <description>&lt;P&gt;ballardw,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have a lot of valid principles mentioned here, but note ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro language automatically applies %eval to the expressions on the %DO statement (from, to, and by values).&amp;nbsp; So this would work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%to (4 + 5)&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 16:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329503#M271795</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-02T16:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Convert to MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329528#M271796</link>
      <description>&lt;P&gt;Check the docs for the SYSFUNC function, INPUT is not valid function. You can use INPUTC INPUTN instead as required.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need it though. INPUT converts the type, but in a macro it will already look like a number so it's fine.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 18:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-to-MACRO/m-p/329528#M271796</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-02T18:50:05Z</dc:date>
    </item>
  </channel>
</rss>

