Search code examples
sassas-macro

Calling macro variables in SAS


I'm working with SAS enterprise 7.1 and I would like to know if there's any difference between calling a macro variable with &var. vs &var, that is, without the final dot. In general, I see that both methods work, but I would like to know if there's something that I'm missing. Thanks in advance!


Solution

  • Consider the scenario below:

    %let myVar = Demo;
    
    libname example "/home/myName/&myVar85";
    

    SAS will look for the macro variable &myVar85 here. But my macro variable is only myVar....so adding a period tells SAS this is the end of the macro variable and to resolve it.

    libname example "/home/myName/&myVar.85";
    

    If you were using it as part of the file path remember to add an extra . for the extension.

    ods excel file="/home/myName/&myVar..xlsx" style=meadow;
    
    proc print data=sashelp.class;
    run;
    
    ods excel close;