Help using Base SAS procedures

Macro bugs

Reply
N/A
Posts: 1

Macro bugs

What's wrong?

%macro bugs;
data person;
   infile datalines delimiter=',';
   input name $ dept $;
   datalines;                     
John,Sales
Mary,Acctng
;
run;
%mend;

%bugs;

1                                                          The SAS System                        17:16 Wednesday, September 26, 2012

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %_eg_hidenotesandsource;
17        
18         %macro bugs;
19         data person;
20            infile datalines delimiter=',';
21            input name $ dept $;
22            datalines;
23         John,Sales
24         Mary,Acctng
25         ;
26         run;
27         %mend;
28        
29         %bugs;

ERROR: The macro BUGS generated CARDS (data lines) for the DATA step, which could cause incorrect results.  The DATA step and the
       macro will stop executing.
NOTE: The data set WORK.PERSON has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
     

ERROR: The macro BUGS will stop executing.
30        
31         %_eg_hidenotesandsource;
43        
44        
45         QUIT; RUN;
46        

But "

data person;

   infile datalines delimiter=',';

   input name $ dept $;

   datalines;                     

John,Sales

Mary,Acctng

;

run;

"

is correct!

Trusted Advisor
Posts: 2,116

Re: Macro bugs

Posted in reply to nikolay_erney

This is working as intended.  Macros are compiled before the data step is run so they can't have DATALINES statements and data.

Ask a Question
Discussion stats
  • 1 reply
  • 184 views
  • 1 like
  • 2 in conversation