Introduction to MACROS in SAS

21 September, 2018

Related Blogs


- Using macros language, we can customize and reduce SAS language. - Using macros language, we can develop reusable application. - Macros language is character based language. - If we want to develop macro application in SAS, we need 2 requirements
  1. Macro compiler or Processor
  2. Macro language


This is one of the part in SAS.  


It can be used interact with macroprocessor.  

Macrotiggers (%,&):

It can be used to identify macrolanguage.  

Percentage (%):

This is called macro reference Each and every macro statement starts with %.  


This is called macrovariable reference. It can be used for reporting macrovariable. - Macro coding can be written outside and inside of the macroblock. - Macro block starts with % macro and requires name of the macro and closed with % mend.
Desired to gain proficiency on SAS? Explore the blog post on SAS Training Online to become a pro in SAS.


% Macro <Macroname>; SAS coding (include dataset block, proc block, open code) % Mend; we run the macro application, SAS do compilation and stores compilation coding in catalog. Catalog name same name of macro.   Macro Call: To call required macro for execution. Syntax: % <Macroname>; Eg:          %macro print; proc print; run; % mend; data demo; input pid age; cards; 100   89 101   90 ; % print; data medi; input pd drug &; cards; 100   5mg 101   6mg ; % print; - Catalog defaults stores in work library.  

Concepts In Macro Language:

  • Macro variables creation
  • Passing arguments to macros
  • Macro quoting function
  • Macro options.
  • Macro expressions
  • Macro interface functions.
For indepth knowledge on SAS, click on below