if fref^=_blank_ then do;
   rc=fileexist(fname);
   if rc=0 then _msg_='The specified file does not exist';
   else do;
      viewid=open("sashelp.vextfl(where=(xpath="
                  ||quote(fname)||"))");
      allocated=attrn(viewid,'any');
      if allocated then do;
         rc=fetch(viewid);
         oldref=getvarc(viewid,varnum(viewid,'fileref'));
         _msg_='The specified filename is already allocated as '
               ||oldref;
      end;
      else do;
         rc=filename(fref,fname);
         if rc=0 then _msg_='Fileref '||fref||
                            ' has been assigned.';
         else _msg_='The filename could not be assigned.';
      end;
      viewid=close(viewid);
   end;
end;