The SAS Output Delivery System and reporting techniques

Shared Code - Best Practices

Reply
N/A
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?
SAS Super FREQ
Posts: 8,742

Re: Shared Code - Best Practices

Hi:
If you refer to these user-group presentations
http://www2.sas.com/proceedings/sugi23/Coders/p81.pdf
http://www2.sas.com/proceedings/sugi31/014-31.pdf
http://www2.sas.com/proceedings/forum2007/006-2007.pdf
http://www2.sas.com/proceedings/sugi27/p021-27.pdf

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.

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 104 views
  • 0 likes
  • 2 in conversation