<?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: SAS 9.4 stops working when using a macro - what do I miss? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619787#M182046</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I kindly disagree with your statement, please see the log:&lt;/P&gt;&lt;PRE&gt;11    %macro test;
12      where AGE &amp;gt; 12;
13    %mend test;
14
15    data class;
16      set sashelp.class;
17      %test;
18    run;

NOTE: There were 12 observations read from the data set SASHELP.CLASS.
      WHERE AGE&amp;gt;12;
NOTE: The data set WORK.CLASS has 12 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jan 2020 10:11:39 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2020-01-24T10:11:39Z</dc:date>
    <item>
      <title>SAS 9.4 stops working when using a macro - what do I miss?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619781#M182042</link>
      <description>&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;My SAS 9.4 base stops executing when I try to run my script. I realise that I'm missing some fundamental part, by I cannot figure it out&amp;nbsp;&lt;/P&gt;&lt;P&gt;----------script---------&lt;/P&gt;&lt;P&gt;options nofmterr;&lt;/P&gt;&lt;P&gt;libname a 'path';&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if amount&amp;lt;0 then amt_cat=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&amp;nbsp;if&amp;nbsp; 0&amp;lt;amount&amp;lt;100 then amt_cat=100;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&amp;nbsp;if amount &amp;gt;=100 then amt_cat=1000;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;set sashelp.buy;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;%test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;----end of script------&lt;/P&gt;&lt;P&gt;When I have run the macro.part, SAS stops executing everything I submit - I can't figure out why.&lt;/P&gt;&lt;P&gt;I consider myself an experienced user, but today I'm clueless.&lt;/P&gt;&lt;P&gt;Many thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 09:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619781#M182042</guid>
      <dc:creator>kiranp</dc:creator>
      <dc:date>2020-01-24T09:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS 9.4 stops working when using a macro - what do I miss?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619783#M182043</link>
      <description>&lt;P&gt;There is nothing obvious in the code you have posted to cause any problems. Please post your SAS log.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 09:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619783#M182043</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-01-24T09:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS 9.4 stops working when using a macro - what do I miss?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619784#M182044</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/109703"&gt;@kiranp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can't use a macro inside a data / a proc step.&lt;/P&gt;
&lt;P&gt;Here is something you can do :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test (tabin = , tabout = );
	data &amp;amp;tabout;
		set &amp;amp;tabin;
                if amount&amp;lt;0 then amt_cat=0;
               else if  0&amp;lt;amount&amp;lt;100 then amt_cat=100;
               else if amount &amp;gt;=100 then amt_cat=1000;
        run;
%mend test;

%test (tabin = sashelp.buy, tabout= work.want);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code includes to macro parameter (the input table, the output table) that you specify when you call the macro %test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, I think there is a misunderstanding of the Libname statement -&amp;gt; 'a' is a library (like a virtual folder) and not a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 09:49:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619784#M182044</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-24T09:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAS 9.4 stops working when using a macro - what do I miss?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619787#M182046</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I kindly disagree with your statement, please see the log:&lt;/P&gt;&lt;PRE&gt;11    %macro test;
12      where AGE &amp;gt; 12;
13    %mend test;
14
15    data class;
16      set sashelp.class;
17      %test;
18    run;

NOTE: There were 12 observations read from the data set SASHELP.CLASS.
      WHERE AGE&amp;gt;12;
NOTE: The data set WORK.CLASS has 12 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 10:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619787#M182046</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-01-24T10:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS 9.4 stops working when using a macro - what do I miss?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619788#M182047</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/109703"&gt;@kiranp&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible that you by any chance selected &lt;STRONG&gt;only&lt;/STRONG&gt;&amp;nbsp;the `%macro test;` part and run it? In such case SAS would wait for all the remaining info to build a macro without executing any code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 10:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619788#M182047</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-01-24T10:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS 9.4 stops working when using a macro - what do I miss?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619789#M182048</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/109703"&gt;@kiranp&lt;/a&gt;, please try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Closing your SAS session and opening it and then trying the code again, as previous issues can cause problems with the SAS session.&lt;/LI&gt;
&lt;LI&gt;Please show us what is in the log, by copying and then pasting it using the "{i}" icon ("Insert Code") when typing your response.&lt;/LI&gt;
&lt;LI&gt;Also, try the data step without any macro code and see what happens (sharing the log again if necessary) e.g.:&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
   set sashelp.buy;

   if amount&amp;lt;0 then amt_cat=0;
   else if  0&amp;lt;amount&amp;lt;100 then amt_cat=100;
   else if amount &amp;gt;=100 then amt_cat=1000;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 10:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619789#M182048</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-01-24T10:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS 9.4 stops working when using a macro - what do I miss?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619790#M182049</link>
      <description>&lt;P&gt;I can run this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
                if amount&amp;lt;0 then amt_cat=0;
               else if  0&amp;lt;amount&amp;lt;100 then amt_cat=100;
               else if amount &amp;gt;=100 then amt_cat=1000;
%mend test;
data a;
   set sashelp.buy;
   %test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in my SAS UE without any problems. Start a fresh session and run &lt;EM&gt;this code only&lt;/EM&gt; for verification.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 10:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619790#M182049</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-24T10:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS 9.4 stops working when using a macro - what do I miss?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619806#M182052</link>
      <description>&lt;P&gt;&lt;SPAN&gt;BIG THANKS to all ideas!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I solved it by including my statements into a dataset, but I can't understand why my initial version works for only a few people.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 12:54:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619806#M182052</guid>
      <dc:creator>kiranp</dc:creator>
      <dc:date>2020-01-24T12:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS 9.4 stops working when using a macro - what do I miss?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619862#M182073</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/109703"&gt;@kiranp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;BIG THANKS to all ideas!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I solved it by including my statements into a dataset, but I can't understand why my initial version works for only a few people.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The comment about not using macros in data step may have been missing where you place the macro. Macros will not work in a DATALINES or CARDS section:&lt;/P&gt;
&lt;P&gt;Attempting to replace the data in this step:&lt;/P&gt;
&lt;PRE&gt;data junk2;
  input x y;
  datalines;
1 2
3 4
;
run;&lt;/PRE&gt;
&lt;P&gt;With&lt;/P&gt;
&lt;PRE&gt;%macro somedata();
1 2
3 4
%mend;


data junk2;
  input x y;
  datalines;
%somedata()
;
run;&lt;/PRE&gt;
&lt;P&gt;will get a log similar to:&lt;/P&gt;
&lt;PRE&gt;NOTE: Invalid data for x in line 52 1-11.
NOTE: LOST CARD.
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--
53         ;
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
x=. y=. _ERROR_=1 _N_=1
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set USER.JUNK2 has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


53   ;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jan 2020 16:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-9-4-stops-working-when-using-a-macro-what-do-I-miss/m-p/619862#M182073</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-24T16:40:18Z</dc:date>
    </item>
  </channel>
</rss>

