Wednesday, January 21, 2009

a special function for %sysfunc world: filename function

Below are the code from SAS online doc:
%let filrf=myfile;
%let rc=%sysfunc(filename(filrf, physical-filename));
%if &rc ne 0 %then
%put %sysfunc(sysmsg());
%let rc=%sysfunc(filename(filrf));

It should be noted that the fileref is "myfile", not "filerf". That means the macro variable "filerf" contains the ACTUAL fileref.
When the macro variable does not exist, the system generates a fileref automatically.

It seems that it is unique to filename function.
For now, I have not found any other functions which can take the similar behavior.

Note that it will not work if the fileref has been assigned. For more information, please see http://support.sas.com/kb/6/567.html

No comments: