The SAS Output Delivery System and reporting techniques

Shared Code - Best Practices

Posts: 0

Shared Code - Best Practices

I am new to SAS and intend to use SAS to generate some complex analyses on multiple datasets. A significant portion of the analyses is the same for each dataset. I'm looking for some guidance on how best to implement these analyses so that code is shared rather than copied.

Can someone direct me to a resource (book, document, etc) that can help me?
Posts: 9,105

Re: Shared Code - Best Practices

Posted in reply to deleted_user
If you refer to these user-group presentations

you will see that a lot of folks use the SAS Macro Facility as part of their source code management system.

In order to effectively use the SAS macro facility, you should
1) have a working SAS program
2) convert that program to use macro variables (i.e. change the program to use a few macro variables like dataset name)
3) convert the program with generic macro variables into a MACRO program and
add any conditional macro programming logic at this point (if it's the last day of the month, then also generate and execute the month-end report code).
4) have a system of organized folders, directories and file names where the data and programs live

The SAS documentation has extensive material on the use of the SAS Macro Facility and there are many books by users published by SAS Press on the topic.

Your use of the SAS Macro facility can be as simple or as complex as you need. But the key is to first have a working SAS program before you try to convert it to use SAS macro processing.

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation