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!
This is working as intended. Macros are compiled before the data step is run so they can't have DATALINES statements and data.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.