P_MACRO: Parameters Extraction from Macros to SAS Dataset


November 7, 2024

In clinical development, SAS programmers manage, analyze, and interpret clinical data, helping to ensure accuracy, which is essential for regulatory submission and approval. SAS programmers may also create new programs to conduct this work more efficiently and effectively.

SAS has a powerful programming feature called Macros, which allows programmers to avoid repetitive sections of code and to use them again and again when needed. It also helps create dynamic variables within the code that can take different values for different run instances of the same code.

Parameters are local to the macro that defines them. A parameter list can contain any number of macro parameters separated by commas. These macro parameters are variables whose values are initialized when we invoke the macro and provide flexibility to supply different values at each invocation. However, there is currently no automated facility within SAS where a complete list of macro parameters defined for a group of macros can be easily checked

Our solution is P_MACRO, which has been programmed to help programmers refer to the complete list of parameters defined within a macro program within the SAS environment itself. Here, I discuss what P_MACRO is capable of, why it’s needed, how it’s programmed, and its limitations.

 

What is P_MACRO and what does it do?

P_MACRO is an SAS program that extracts parameter-level information from a group of macros and saves them to an SAS dataset. Once set up, P_MACRO accomplishes several tasks, including:

  1. Extracting parameters from the group of macro programs to the SAS dataset.
  2. Extracting default values along with parameters, if already defined.
  3. Retaining the order of parameters.
  4. Prioritizing main macro information over nested macros.
  5. Providing a common text for macro programs without parameters.
  6. Generating an automated macro call.

 

Why is P_MACRO needed?

In SAS macros, we have the flexibility to exclude some parameters at invocation and the macro will still execute well, if there is no dependency. But when we do not include the complete list of parameters in a call, it is difficult for the programmer to decide on adding parameters to the existing call when an update/modification is needed. If the programmer is not aware of the complete list of parameters when an update is needed, then they may need to either use debugging options or manually open the macro code and check.

However, we do not have an automated facility within SAS where we can check the complete list of macro parameters defined for a group of macros. Thus P_MACRO, when released for wider group usage, will help programmers gather and refer to the complete list of parameters defined within a macro program in the SAS environment itself. With this, it will be easy to get ahold of the complete list of parameters defined along with their default values and position/order. An automatic macro call for each macro is generated using the information stored in resultant dataset, saving valuable time for the programmer.

 

Steps involved in P_MACRO programming

  1. Read macro program files to SAS
  2. Extract macro name
  3. Determine macro start and end points
  4. Handle nested macros
  5. Handle macro programs with no parameters
  6. Retain macro parameters position
  7. Bring out default values
  8. Generate macro call

 

Limitations

Despite its benefits, the P_MACRO program has a few limitations:

  1. %LET statement is used in macro programs to conditionally check and assign a default value for a parameter. Such default values are not extracted through the macro.
  2. SAS Macros has the ability to use the PARMBUFF option and SYSPBUFF to define a macro that accepts a varying number of parameters at each invocation. In such cases, P_MACRO won’t be able to extract any parameters.

 

Final takeaways

In the SASHELP library, there is a dataset named VCOLUMN that holds detailed information about the metadata of the libraries, datasets, and variables present for that SAS session. This helps programmers to identify/query some of the important information about the datasets/variables for that active session. Like the VCOLUMN dataset, the dataset generated through P_MACRO will help programmers find the list of macros within one folder, with their entire list of parameters in defined order along with default values in one place within SAS. Generating an automated macro call using the resultant dataset would help programmers by having the entire parameters list handy and ready to use as needed.

 

Interested in learning more?  

Eswara Gunisetti will be at PHUSE EU 2024 to present “P_MACRO, Parameters Extraction from Macros to SAS Dataset” on Wednesday, November 13 at 12:00 p.m. We hope to see you there!

Book a meeting!
Subscribe to our newsletter

Eswara Gunisetti

Manager, Statistical Programming Management

Eswara Gunisetti is Manager, Statistical Programming Management, at Cytel. Eswara has over fourteen years of experience in the Clinical SAS industry. He has worked for multiple therapeutic areas, including Neuroscience, Oncology, and Biosimilars, among others. He has extensively used CDISC standards, such as SDTM and ADaM and has led multiple submission studies for regulatory authority approval. Before joining Cytel, Eswara worked for Parexel, Novartis, and IQVIA. Eswara is Project Management Professional (PMP) certified and holds a master’s in pharmacy from Jawaharlal Nehru Technological University Kakinada (JNTUK), India.

Read full employee bio

Claim your free 30-minute strategy session

Book a free, no-obligation strategy session with a Cytel expert to get advice on how to improve your drug’s probability of success and plot a clearer route to market.

glow-ring
glow-ring-second