As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

Solutions in the Round -- Using the SAS Macro Facility--What Do You %Include; ? (WUSS)

From sasCommunity
Jump to: navigation, search


From the WUSS abstract for this topic

The SAS Macro Facility can be utilized to make coding much easier. This session will provide a practical overview of SAS macro programming in order to raise your programming functionality to a higher level. Solutions in the Round (SITR) is a roundtable format section where attendees discuss approaches and solutions to a programming problem or SAS topic. Users from different perspectives and all experience levels are encouraged to participate.

Discussion at WUSS


Richann Watson (RW)

- long-time SAS programmer (coder)

Josh Horstman (CS), Looking Glass Analytics

- parent of CDISC for medical devices

RW: Macro examples

 500 tables, specify by groups, merges
 writing 2-3 days, running 3-5 days (for QC)
 Used more macros to compare

Thomas Billings:

 Adjustments to tables
 -  provide table adjustments or NOT
 -  use excel control sheet to manage datasets

RW: Postiional vs keyword

 Positional: %macname(var1, var2, ..., varN)
 Keyword: %macname(varA=, varB=, ..., varX)

 -  use keyword for maintainability

 JH: use no args
 -  to allow %IF in stream 
 -  RW: coming soon(?): %IF outside of macro

TB: Macros Functions are great for substitutions

 - use like "function" *without* semicolon for in-line substitutions

Q: debugging

 RW:  additional options, like nested levels 
 U: %macrolog() to write out macros and nesting 
 RW: %include / source 
 -  enables tracing of 
 TB: can add %put for debugging
 -  e.g. _all_
 RW: add global macro var "DEBUG=N"
 -  %IF(debug==Y), enable debug logging
 -    N ==> use in production
 RW:  Indent!!

Q: lots of code, similar

 - 19 reports, ICD-10 codes (for death codes) differ
 - Need different files
 RW: use code & file are macro args
 -  file is optional if using standard filename pattern with 
 PROC REPORT / ODS with .PDF out
 TB: could use BY processing if single 

Q: best practices ?

 RW:  Develop as stand-alone data / proc steps
 -> convert to macro
 - learn SAS MACRO
   --  e-learning at
   --  might have extra seats 

Q: Macros and EG?

 BJ:  YES, EG actually uses macro under the covers
 U: EG is good to learn SAS Macros
 -  code EG, then open code nodes to learn SAS macro and/or procs

Further Discussion -- Open to All

Please join the conversation! Also, if you were one of the live participants, please feel free to correct any mistakes or omissions from our original discussion.