DATA Step, Macro, Functions and more

ERROR: An unexpected semicolon occurred in the %DO statement.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

ERROR: An unexpected semicolon occurred in the %DO statement.

Can anyone help with the above error when running this small section of code below?

 

%macro start;

 

%if &i_creative. = 1 %then %do

data &tmp_filelist.;

length filename $150;

run;

%end;

%else %if &i_creative. >1 %then %do

proc append base=&tmp_filelist. data=&tmp_filelist2. force;

run;

%end;

 

%mend start;


Accepted Solutions
Solution
‎02-19-2016 09:41 AM
Respected Advisor
Posts: 3,777

Re: ERROR: An unexpected semicolon occurred in the %DO statement.

You need to add a semicolon after the word

 

%DO;

In both lines where it appears.

View solution in original post


All Replies
Super User
Posts: 6,936

Re: ERROR: An unexpected semicolon occurred in the %DO statement.

You are missing semicolons to end the macro %do statements:

%macro start;
%if &i_creative. = 1 %then %do;
data &tmp_filelist.;
length filename $150;
run;
%end;
%else %if &i_creative. >1 %then %do;
proc append base=&tmp_filelist. data=&tmp_filelist2. force;
run;
%end;
%mend start;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎02-19-2016 09:41 AM
Respected Advisor
Posts: 3,777

Re: ERROR: An unexpected semicolon occurred in the %DO statement.

You need to add a semicolon after the word

 

%DO;

In both lines where it appears.

Occasional Contributor
Posts: 16

Re: ERROR: An unexpected semicolon occurred in the %DO statement.

Ah yes of course - such a schoolgirl error.

 

Curse SAS with it's misleading error messages!

Super User
Posts: 17,826

Re: ERROR: An unexpected semicolon occurred in the %DO statement.

Just a note that you don't need that piece of code.

 

PROC APPEND doesn't require the base data set to preexist, so you only need the last section.

 

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 539 views
  • 2 likes
  • 4 in conversation