Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (SAS Complete Course) expand_more
SAS Complete Course / Macro Language

%MACRO and %MEND

Learn %MACRO and %MEND in SAS through the exact construct, a dedicated example, a boundary case, and a mastery check.

12 min read • Advanced

%MACRO and %MEND is an atomic SAS lesson inside Macro Language. The example uses the specific syntax, command, API, instruction, or language rule named by this lesson.

Study the construct itself, then change one relevant input and predict the result before running it. That keeps this lesson focused on %MACRO and %MEND rather than on generic SAS syntax.

Topic-specific example

sas-07-03.sas
sas Try It Live
%macro greet(name); %put Hello &name.; %mend; %greet(Ava);
Edge case / engineering note

For %MACRO and %MEND, inspect the SAS log as well as the output data set; type conversion, missing values, and BY-group ordering can change results without stopping execution.

Content source & attribution
Original Syntaxis Content · Original Syntaxis Content