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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.