BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
xxformat_com
Barite | Level 11

Hi,

I've heard for the first time during a SAS Institute webinar that no semi-column should be used after a macro call. The reason is that it would occasionally create a bug. I've programmed over 20 years in SAS using a semi-column without encountering any issue. Do you know about more about this rule? Was it always the case? Do you have an example of issue?

Kind Regards,

1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5
PaigeMiller
Diamond | Level 26

I have heard this, and I never use a semi-colon after a macro call.

 

However, I cannot provide an example where the semi-colon after the macro call causes a problem.

--
Paige Miller
Tom
Super User Tom
Super User

The rule is that you cannot insert a sem-colon into the middle of a statement. 

But extra semi-colons between statements normally does not cause any trouble (which is probably why you have not had any issues).

 

So if the macro generates only part of statement (some times call macro functions) then adding a semi-colon after the macro function call would insert the semi-colon into the middle of the statement.

 

xxformat_com
Barite | Level 11
Thanks Tom
Kurt_Bremser
Super User

See this:

%macro datasets;
%do y = 2000 %to 2021;
  ds_&y.
%end;
%mend;

data want;
set
  %datasets; /* this semicolon causes trouble */
  indsname=ds
;
dsname = ds;
run;
xxformat_com
Barite | Level 11
Thanks Kurt. Thanks Tom. I see now.
I never use a macro call directly within a data step, procedure or global statement. I only use it as standalone or within quotes in a put statement/call execute routine. So it explains it all.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 474 views
  • 7 likes
  • 4 in conversation