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,799

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

Posted in reply to kimdukes77

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: 7,827

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

Posted in reply to kimdukes77

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,799

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

Posted in reply to kimdukes77

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.

Posted in reply to data_null__

Ah yes of course - such a schoolgirl error.

 

Curse SAS with it's misleading error messages!

Super User
Posts: 19,822

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

Posted in reply to kimdukes77

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
  • 654 views
  • 2 likes
  • 4 in conversation