Monday, 18 July 2011

Creating A Macro Using Data From An Existing Table!

This is a simple piece of code that I use in most of the projects that I create.


PROC SQL noprint;
select distinct age into :agelist separated by ',' from agedataset;
quit;

The code above takes all of the ages from the data set conveniently called agedataset, and places them into a macro (also conveniently) called agelist. This list of ages within the macro is then separated via commas (',').

Now if I want to filter another table for only the ages within the agedataset, all I need to do is filter for ages IN &agelist and SAS will do the rest for me!

No comments:

Post a Comment