Date: Fri, 19 Oct 2007 07:21:57 -0400
Reply-To: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Organization: Internet News Service
Subject: Re: Overriding LIBNAME and FILENAME statements
> But of course this does not work since the filename in production.sas
> reassigns the filename to the original production location.
> Is there a technique that I can use to override the filename in this
> Paul OldenKamp
You are not really overriding, you are attempting to prevent overriding. It
would be nice for you if there were a no 'NOREASSIGN' filename option:
FILENAME myFile "where-ever" ONREASSIGN=(Allow|Note|Warn|Error);
But there ain't.
One way to prevent the production code from reassigning lib refs is to lock
them. You _will_ get an ERROR when the production code does try to
reassign -- which, depending on session option settings, might cause the
session to abend or go into error check mode.
How do you lock a libname ? Open a resource and never close it.
%let work = %sysfunc(pathname(work));
dir1 = dcreate ('foo-prod', "&work.");
dir2 = dcreate ('foo-dev', "&work.");
* create and open a resource;
libname foo "&work.\foo-dev";
%let ds = %sysfunc(open(foo.tag));
* try to change the libref;
libname foo "&work.\foo-prod";
This idea does not work for filerefs. When a fileref is locked it cannot be
'used' in a separate step (post failure of production code to reassign it).
The best approach is to have a development environment, or design the
production code to run off parameters passed into it.
Richard A. DeVenezia