Search code examples
sasfilenamessas-macro

SAS macro output file naming conventions


I have a sas macro which is dependent on two varying variables Age and Year represented by &Age and &Year respectively.

I want to run the macro for each combination of the ages 15-18 and years 2007-2010 and wish to create an output table for each of these combinations (i.e. 16 tables in total).

Here is my problem, I try to give the output table the following name in the macro Matrix_pop_adm&Age_RP&Year which SAS doesn't like.

How can I name my output file correctly ?


Solution

  • As you're concatenating macro variables into a string with other delimiting characters, you need to add dots to make each distinct macro variable resolve (in this case) independently.

    Matrix_pop_adm&Age._RP&Year 
    /*                ^ force &AGE to resolve, instead of trying to resolve &Age_RP */