02-16-2012 10:11 AM
I have a program that others in my department need to use. Within this program I want to create a permanent libname so each user who runs this program will always have this libname.
Is there an option to the libname statement that will cause the libname to become permanent?
I don't have access to each users autoexec.sas or else I could put it there. I need it to happen in my program.
Is this possible?
Thank you so much
02-16-2012 10:21 AM
There is always a risk that you will override someone's existing libname or that they may override the one you assign.
An alternative you might be able to use is to use proc sql, and a view in which you imbed the libname in the code. That could work as the imbedded libname is local to the proc sql run and won't cause any conflicts.
If that is a possibility, take a look at: http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/viewer.htm#a001395624.htm
02-16-2012 10:26 AM
Thank you so much for your reply. This will only be used for certain people and the libname we will use they will be sure to know what it is as not to overwrite.
I was hoping there was an option in the libname statement something like startup=yes.
Can this be done in a regular sas program?
Thanks again for all your help.
02-16-2012 11:28 AM
One approach would be to an and %INCLUDE statement to the AUTOEXEC.SAS file pointing to a common SAS program assigning LIBNAMES. Then each time their SAS session starts it would have the libraries available and the code would reflect any changes you made.
If they don't have an AUTOEXEC.SAS file then you would modify the SAS configuration file, look for something like SASV9.CFG and add a line like:
to point to a common autoexec with the code.
02-16-2012 12:34 PM
Thanks for the reply.
My issue is I can not use the autoexec.sas or the config file it has to happen within my program. This way when the select users use it I know that the libname will always be there for them when they use specific apps and programs.
02-16-2012 02:17 PM
It is obviously your call but, if a user were to go to tools and assign a libname as being permanent, it would result in being added to the sas registry.
I think you may have misunderstood what I was suggesting.
Say you had the following lines in a text file called s:\testreg where s was some network drive that everyone had access to:
If you were to have everyone run the following code, the libary project would always appear whenever they open subsequent sas sessions:
proc registry import="s:\testreg";
I obviously could be wrong, but I thought that was what you were trying to accomplish.
02-16-2012 12:36 PM
I don't understand.
In your program you have LIBNAME NAME 'path';
When the program runs should the path not exist you can create it with DCREATE.
Or is it the path that you need to somehow derive based on user specific info?
Or do you need make this LIBNAME known to all future SAS session/programs?
02-16-2012 12:59 PM
I'm with you. I don't understand either.
If you want your users to have a program with a permanent libname, why not put the LIBNAME statement in the program?
If the path has to change from one user to the next, why not give each user a program with two lines in it: a LIBNAME statement tailored to that user,
and a %include statement to fetch your program?
02-16-2012 01:13 PM
DataNull: I think the OP wants to make the LIBNAME known to all future sessions. I was wondering if the method proposed by Richard http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0701C&L=sas-l&P=23578
could be modified to accomplish it?
02-16-2012 01:54 PM
Are you saying that you don't want the users to know the LIBNAME definitions? You might be able to hide them from a user, but you can't hide them from a programmer. Once a LIBNAME has been defined, SAS saves that in the session's metadata (dictionary tables).
Question: Are users set up with a macro autocall library defined?
Question: Does your operating system allow you to have complete access to a file, but users to have read access only to that file?
02-16-2012 01:17 PM
I want this libname for future programs and apps to access.
For example say I write a sas program with my libname and there is a way to make it permanent. The next time I send out a sas program I already know the user has this libname to the data we are working with.
Thank you for your help
02-16-2012 01:23 PM
Here's a practical approach then.
Store all LIBNAME statements in a file.
Redefine one of the user's function keys within SAS to go to the Program Editor, %include the file, and run it.
The user will still have to hit the function key of course.
That way, you can even update the LIBNAMEs in the future and the users wouldn't have to change what they do.