<?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: Error with macro to create forward values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Error-with-macro-to-create-forward-values/m-p/611924#M18253</link>
    <description>&lt;P&gt;The syntax for FIRSTOBS= must take a number, not an expression.&amp;nbsp; Have the macro processor resolve the expression into a number before the DATA step "sees" it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;firstobs=%eval(&amp;amp;i+1)&lt;/P&gt;</description>
    <pubDate>Sun, 15 Dec 2019 22:59:00 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-12-15T22:59:00Z</dc:date>
    <item>
      <title>Error with macro to create forward values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-with-macro-to-create-forward-values/m-p/611923#M18252</link>
      <description>&lt;P&gt;Hi! I'm trying to create leads for the variable "annualearn" and I want to call them&amp;nbsp;earn_t&amp;amp;i. For that, I am writing the following macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro forwardearn;&lt;BR /&gt;%do i=1 %to 7;&lt;BR /&gt;data analysis30;&lt;BR /&gt;set analysis30;&lt;BR /&gt;if eof&amp;amp;i=0 then&lt;BR /&gt;set analysis30 (firstobs=&amp;amp;i+1 keep=annualearn rename=(annualearn=earn_t&amp;amp;i)) end=eof&amp;amp;i;&lt;BR /&gt;else earn_t&amp;amp;i=.;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%forwardearn;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I get the error:&amp;nbsp;&lt;SPAN&gt; ERROR 22-7: Invalid option name +. , which I think it refers to the + in&amp;nbsp;firstobs=&amp;amp;i+1 (only + in the macro).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone have an idea of what I am doing wrong??&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2019 21:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-with-macro-to-create-forward-values/m-p/611923#M18252</guid>
      <dc:creator>julianaram</dc:creator>
      <dc:date>2019-12-15T21:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error with macro to create forward values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-with-macro-to-create-forward-values/m-p/611924#M18253</link>
      <description>&lt;P&gt;The syntax for FIRSTOBS= must take a number, not an expression.&amp;nbsp; Have the macro processor resolve the expression into a number before the DATA step "sees" it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;firstobs=%eval(&amp;amp;i+1)&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2019 22:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-with-macro-to-create-forward-values/m-p/611924#M18253</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-12-15T22:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error with macro to create forward values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-with-macro-to-create-forward-values/m-p/611926#M18254</link>
      <description>&lt;P&gt;This was super helpful. Now it works. Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2019 23:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-with-macro-to-create-forward-values/m-p/611926#M18254</guid>
      <dc:creator>julianaram</dc:creator>
      <dc:date>2019-12-15T23:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Error with macro to create forward values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-with-macro-to-create-forward-values/m-p/611969#M18266</link>
      <description>&lt;P&gt;You should also avoid running multiple steps:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro forward;
data analysis30_a;
merge
  analysis30
%do i = 1 %to 7;
  analysis30 (firstobs=&amp;amp;i+1 keep=annualearn rename=(annualearn=earn_t&amp;amp;i))
%end;
;
run;
%mend;
%forward&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In my experience, the merge without by sets variables to missing when one of the datasets gets past eof.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 07:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-with-macro-to-create-forward-values/m-p/611969#M18266</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-16T07:38:30Z</dc:date>
    </item>
  </channel>
</rss>

