BookmarkSubscribeRSS Feed
R_A_G_
Calcite | Level 5
hello,

What is the difference in ending the macro TYPE1 Vs. TYPE2.
Thanks

TYPE1:
%macro tryit;
*%let dattype=ae;
%let dattype=demog;
*%let dattype=meds;
***********************;
%put data type is &dattype;
%mend tryit;
%tryit

TYPE2:
%macro tryit;
*%let dattype=ae;
%let dattype=demog;
*%let dattype=meds;
***********************;
%put data type is &dattype;
%mend;
%tryit;
5 REPLIES 5
SusieQ324
Fluorite | Level 6
Syntax-wise, I think you'll need to state the macro name in TYPE2 on your %mend statement. But other than that, invoking the macro is the same.
Cynthia_sas
SAS Super FREQ
Hi:
As the documentation says
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000206958.htm
-- repeating the macro name is not required, but is very useful for clarity, especially when a job might have more than 1 definition for a macro program inside.

cynthia
R_A_G_
Calcite | Level 5
thanks for always helping
RickM
Fluorite | Level 6
You don't really need the macro name in the %mend statement. It just helps you keep track of which macro you just ended. There is no difference between the two types.
chang_y_chung_hotmail_com
Obsidian | Level 7
In case you are asking if we should invoke a macro with or without a trailing semi-colon:



   %macro test;


      %let dattype=demog;


      %put data type is &dattype;


   %mend test;


 


   %*-- type1 --*;


   %test


 


   %*-- type2 --*;


   %test;





It depends. A macro invocation does not require a semi-colon, but anything that can signal the end of the invocation. Thus if your macro generates a complete statement including the statement ending semi-colon, then the type 2 style invocation results in an extra semi-colon. This is often OK, though, if the extra semi-colon, in the context, can be considered as a null statement and is ignored.

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 845 views
  • 0 likes
  • 5 in conversation