user_12345
user_12345

Reputation: 103

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!

Upvotes: 0

Views: 294

Answers (2)

Daniel Thomas
Daniel Thomas

Reputation: 137

For consistency it's best to always finish with a ".", I reckon. Indeed, the need is not always there, but the use case outlined above hopefully explains why "." is sometimes needed :)

Upvotes: 1

Reeza
Reeza

Reputation: 21294

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;

Upvotes: 0

Related Questions