BookmarkSubscribeRSS Feed
nikolay_erney
Calcite | Level 5

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!

1 REPLY 1
Doc_Duke
Rhodochrosite | Level 12

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

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1603 views
  • 1 like
  • 2 in conversation