Several libraries I work with were stored on a network drive. That drive was failing, so our network services group moved my directories to another drive in the system. Now my libraries are broken in SAS. When I try to get properties it says it doesn't exist.
I just need the path name SAS thinks it wants and I can easily repair the connection, but some of them will take some time to reconstruct if I have to figure it out manually.
Is there an easy way to pull up this information? A config file or something?
Hi @iiibbb,
If you know the librefs, you can use the PATHNAME function to obtain the corresponding paths.
Example:
data _null_;
input libref $;
length path $1000;
path=pathname(libref);
put libref $9. path=;
cards;
maps
sasuser
work
yourlib
;
Hi,
Do you have any previous SAS logs that you can refer to?
Is there any existing code where the paths are assigned to a library name?
Can you perform a textual search on your files?
Thanks & kind regards,
Amir.
Hi,
When you say "Instead it just says that the library no longer exists", is this a log? If it is a log, can you see if there is a path in the log.
If it is not a log then what is "it"? Please provide evidence either way, e.g., text from the (using the Insert Code icon "</>") for a log or a screen shot in the case of a pop-up.
In the case of a log, ensure option source is on. Also, if macros are being used then it might be worth switching on the macro options mprint symbolgen.
Kind regards,
Amir.
Where did you store the code that assigned libraries? Or how are your libraries assigned?
Hi @iiibbb,
If you know the librefs, you can use the PATHNAME function to obtain the corresponding paths.
Example:
data _null_;
input libref $;
length path $1000;
path=pathname(libref);
put libref $9. path=;
cards;
maps
sasuser
work
yourlib
;
First time I tried this it didn't work. Didn't change anything and ran it again and it worked perfectly.
Go figure.
Thank you.
I assume you mean that you are trying to use a libref, like MYLIB, that is still pointing to the old location.
To point MYLIB at the new location just run a new LIBNAME statement.
libname mylib '/path to new location';
But the question I have is how did the libref get defined?
Did you run some SAS code, like the example libname statement above, to make the libref? If so then update that program to use the right path.
Did you somehow define the libref once and SAS is remembering it the next time you startup? If so then you need to go back to the process you used to define the libref and re-define it.
Or just add the code like above the redefine it now.
What interface are you using to run your SAS code?
Are you typing the a command at the command line? Like
sas myfile.sas
In that case look and see if your autoexec.sas file is running the libname command.
Are you using Enterprise Guide?
Are you using SAS/Studio?
Is your site using SAS Metadata Manager to push common librefs to every user?
Follow up question.
Now that I know the path names of these librefs, is there a simple way to change the pathname?
Literally all I need to do is change the Z: to a W:
Z:\2016_SLXHD\1_SAS_DATA\TOUT_DOE\DOE_LEGS |
I'd suggest that you
data _null_;
file 'C:\Temp\libnames.sas';
input libref $;
length path $1000;
path=tranwrd(pathname(libref), 'Z:\', 'W:\');
if path ne:'(' then path=quote(trim(path));
put 'libname ' libref path ';';
cards;
yourlib1
yourlib2
;
%inc 'C:\Temp\libnames.sas';
or copy the code from libnames.sas into your AUTOEXEC file so that the libraries are always made available at startup.
@iiibbb wrote:
Follow up question.
Now that I know the path names of these librefs, is there a simple way to change the pathname?
Literally all I need to do is change the Z: to a W:
Z:\2016_SLXHD\1_SAS_DATA\TOUT_DOE\DOE_LEGS
Wouldn't it just be easier to mount the new disk as Z instead of W? Then the libref definition does not need to change. Part of the reason to use mapped drives. You can change the physical drive without having to change the logical name you use to reference it.
Or are their other folders that are still on the old W drive?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.