<?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: An error when using % macro statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238307#M43778</link>
    <description>You're overwriting your data set with each call. So the first call creates data set gdp3 and then the second call creates a new gdp3 data set, with the source data gdp and everything from the first step is forgotten. You may want to look into a macro loop in your data step instead of multiple calls, as well as a way to store your final data set.</description>
    <pubDate>Tue, 08 Dec 2015 15:49:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-12-08T15:49:29Z</dc:date>
    <item>
      <title>An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238289#M43765</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to run the following macro, a lot of errrors result. I&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro unemp4(ls);&lt;BR /&gt;DATA&amp;nbsp; asmt2.gdp3; &lt;BR /&gt;set asm2.gdp&lt;BR /&gt;L&amp;amp;ls. = LOG(GDP) - LOG (LAG&amp;amp;ls.(GDP));&lt;BR /&gt;S&amp;amp;ls. = LAG&amp;amp;ls.(SPREAD);&lt;BR /&gt;&lt;BR /&gt;PROC&amp;nbsp; REG&amp;nbsp; DATA=asmt2.gdp3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;MODEL&amp;nbsp; L&amp;amp;ls.=S&amp;amp;ls./DWPROB; &lt;BR /&gt;RUN;&lt;BR /&gt;quit;&lt;BR /&gt;%MEND unemp4;&lt;BR /&gt;%unemp4 (1) %unemp4(2) %unemp4 (3) %unemp4 (4)&amp;nbsp; %unemp4(5) %unemp4 (6) &lt;BR /&gt;%unemp4(7) %unemp4 (8)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 15:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238289#M43765</guid>
      <dc:creator>whijazi</dc:creator>
      <dc:date>2015-12-08T15:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238292#M43767</link>
      <description>&lt;P&gt;It would help if you run some of the code with OPTIONS MPRINT; and show the log so we know what type of errors you are getting if syntax errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are getting unexpected value errors you should provide some example input, the erroneous values and the desired values.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 15:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238292#M43767</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-08T15:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238294#M43769</link>
      <description>&lt;P&gt;I have attached the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I am trying to do is instead of writing this long code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA&amp;nbsp; asmt2.gdp3; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SET&amp;nbsp; asmt2.gdp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;L1=LOG(GDP)-LOG(LAG1(GDP)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;L2=LOG(GDP)-LOG(LAG2(GDP)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;L3=LOG(GDP)-LOG(LAG3(GDP)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;L4=LOG(GDP)-LOG(LAG4(GDP)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;L5=LOG(GDP)-LOG(LAG5(GDP)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;L6=LOG(GDP)-LOG(LAG6(GDP)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;L7=LOG(GDP)-LOG(LAG7(GDP)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;L8=LOG(GDP)-LOG(LAG8(GDP)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;S1=LAG1(SPREAD); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;S2=LAG2(SPREAD); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;S3=LAG3(SPREAD); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;S4=LAG4(SPREAD); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;S5=LAG5(SPREAD); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;S6=LAG6(SPREAD); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;S7=LAG7(SPREAD); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;S8=LAG8(SPREAD);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to write a macro version:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro unemp4(ls);&lt;BR /&gt;DATA&amp;nbsp; asmt2.gdp3; &lt;BR /&gt;set asm2.gdp&lt;BR /&gt;L&amp;amp;ls. = LOG(GDP) - LOG (LAG&amp;amp;ls.(GDP));&lt;BR /&gt;S&amp;amp;ls. = LAG&amp;amp;ls.(SPREAD);&lt;BR /&gt;RUN;&lt;BR /&gt;quit;&lt;BR /&gt;%MEND unemp4;&lt;BR /&gt;%unemp4 (1) %unemp4(2) %unemp4 (3) %unemp4 (4)&amp;nbsp; %unemp4(5) %unemp4 (6) &lt;BR /&gt;%unemp4(7) %unemp4 (8)&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 15:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238294#M43769</guid>
      <dc:creator>whijazi</dc:creator>
      <dc:date>2015-12-08T15:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238296#M43770</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Well, firstly, what are the errors you get in the log. &amp;nbsp;You have provided no log, nor test data to run this against. &amp;nbsp;Its not quite clear what your macro is attempting to do, or why all the macro code is necessary. &amp;nbsp;Also note that code formatting is quite important to be clearly readble. &amp;nbsp;One important thing to note, which will cause errors is the missing semicolon after each macro call, update as given below. &amp;nbsp;Also, be sure to put options mlogic mprint symbolgen; on before running.&lt;/P&gt;
&lt;PRE&gt;%macro unemp4(ls);
  data asmt2.gdp3; 
    set asm2.gdp
    L&amp;amp;ls.=log(gdp) - log (lag&amp;amp;ls.(gdp));
    S&amp;amp;ls.=lag&amp;amp;ls.(spread);
  run;

  proc reg data=asmt2.gdp3;
    model&amp;nbsp;l&amp;amp;ls.=s&amp;amp;ls./dwprob; 
  run;
quit;
%mend unemp4;
%unemp4 (1);
%unemp4 (2);
%unemp4 (3); 
%unemp4 (4);&amp;nbsp; 
%unemp4 (5); 
%unemp4 (6); 
%unemp4 (7); 
%unemp4 (8);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 15:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238296#M43770</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-08T15:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238305#M43776</link>
      <description>&lt;P&gt;Adding the missing semicolon after the SET statement will help a lot, I guess.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 15:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238305#M43776</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-12-08T15:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238307#M43778</link>
      <description>You're overwriting your data set with each call. So the first call creates data set gdp3 and then the second call creates a new gdp3 data set, with the source data gdp and everything from the first step is forgotten. You may want to look into a macro loop in your data step instead of multiple calls, as well as a way to store your final data set.</description>
      <pubDate>Tue, 08 Dec 2015 15:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238307#M43778</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-08T15:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238308#M43779</link>
      <description>If you have proc expand, or a SAS/ETS license this is also a lot easier to calculate. It's worth looking into.</description>
      <pubDate>Tue, 08 Dec 2015 15:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238308#M43779</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-08T15:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238309#M43780</link>
      <description>Thanks, I see the issue. I will try a DO loop</description>
      <pubDate>Tue, 08 Dec 2015 15:50:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238309#M43780</guid>
      <dc:creator>whijazi</dc:creator>
      <dc:date>2015-12-08T15:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238310#M43781</link>
      <description>&lt;P&gt;Assuming GDP and SPREAD are variables in the dataset i believe error is from use LAG1()-LAG8() functions as these are not valid sas functions.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 15:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238310#M43781</guid>
      <dc:creator>ndp</dc:creator>
      <dc:date>2015-12-08T15:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238311#M43782</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/26546"&gt;@ndp&lt;/a&gt; Lag&amp;lt;n&amp;gt; is a valid SAS function.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212547.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212547.htm&lt;/A&gt;</description>
      <pubDate>Tue, 08 Dec 2015 15:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238311#M43782</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-08T15:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238320#M43785</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;Thanks should have checked before i responded.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 16:14:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238320#M43785</guid>
      <dc:creator>ndp</dc:creator>
      <dc:date>2015-12-08T16:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: An error when using % macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238333#M43790</link>
      <description>Thanks for your help ndp</description>
      <pubDate>Tue, 08 Dec 2015 16:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/An-error-when-using-macro-statement/m-p/238333#M43790</guid>
      <dc:creator>whijazi</dc:creator>
      <dc:date>2015-12-08T16:48:11Z</dc:date>
    </item>
  </channel>
</rss>

