DATA Step, Macro, Functions and more

Store librefs

Accepted Solution Solved
Reply
Contributor
Posts: 35
Accepted Solution

Store librefs

[ Edited ]

 

Dear community,

 

this time, I would like to ask for your help concerning the following administrative issue:

Now it happened to me three times (after using SAS for ~ five months) that when I open SAS, all my librefs (Explorer View: SAS Environment → Libraries →) where gone.

Am I somehow able to story something like a “profile”, such that I do not have to manually add all old libraries again?

Or, is there are a way to (if I am capable of restoring all locations manually) to write all librefs to a file, such that, if they happen to "vanish" once again, I could recreate them with a SAS-command?

 

I would be glad, if you could help me with this issue.

 

Yours sincerely,

Sinistrum


Accepted Solutions
Solution
‎09-09-2016 05:31 AM
Super User
Posts: 17,842

Re: Store librefs

Find your autoexec file and add your librefs there. 

The following code should show you where your autoexec file is located

%let autox = %str(%sysfunc(getoption(autoexec)));
 %put &autox;

If it's blank you don't have one but you can set one up.

 

http://support.sas.com/documentation/cdl/en/hostwin/67962/HTML/default/viewer.htm#p0bmj7wjme32ayn1h4...

 

 

I would also store a copy elsewhere since something appears to reset your settings. 

View solution in original post


All Replies
SAS Super FREQ
Posts: 683

Re: Store librefs

SAS Libraries are created using the LIBNAME statement.

 

So all you need to do is, save all the LIBNAME statements to a SAS program and run it when you start SAS.

 

Depending on your SAS Environment (SAS University Edition, SAS Installation on your PC, SAS Platform Installation) there might be other options.

 

Bruno

Contributor
Posts: 35

Re: Store librefs

Hello Bruno,

 

thank you for your fast reply.

 

Up untill now, I did not use a LIBNAME state.

I just right-clicked "libraries" and created a new library. With this method, one can use "enable on start up" and everything should be fine, I thought.

 

So, for now, I use the method suggested by you: I create a program and put all the libname statements in it.

 

Is there a way to make them "enabled on startup"?

If I right-lick them in the explorer view, there is no option causing them to be loaded when SAS is started.

 

Sinistrum

SAS Super FREQ
Posts: 683

Re: Store librefs

The "Enable at Startup" can only be specified when you create a new library from the SAS Explorer.

 

This information is stored in the SAS Registry (stored in the SASUSER library).

 

I recommend the approach using a SAS program, since this is portable.

 

Bruno

Solution
‎09-09-2016 05:31 AM
Super User
Posts: 17,842

Re: Store librefs

Find your autoexec file and add your librefs there. 

The following code should show you where your autoexec file is located

%let autox = %str(%sysfunc(getoption(autoexec)));
 %put &autox;

If it's blank you don't have one but you can set one up.

 

http://support.sas.com/documentation/cdl/en/hostwin/67962/HTML/default/viewer.htm#p0bmj7wjme32ayn1h4...

 

 

I would also store a copy elsewhere since something appears to reset your settings. 

Contributor
Posts: 35

Re: Store librefs

[ Edited ]

First of all: Thank you both for responding. I was really in panic this morning; when this first happened to me, I thought, all my data was gone. But now, I assume, that somehow, "just" the settings are reset, as suggested by Reeza (spoiler for my "theory" on this issue).

Spoiler
Sometimes, I, accidentally, double-double-click SAS.exe in order to open it. Then, the "first" SAS.exe would operate normally, the "second" SAS.exe would not have access to the settings, because the "first" SAS is using them. Then, I conveniently close the second SAS and everything works fine.
But maybe, sometimes I double-double-click too fast - then, the settings are corrupted at all.

What I would like to add, is the following:
In addition, other settings are overwritten; e.g., I have it set in general, that, instead of variable-labels, I have variable-names displayed in tableview. This setting I adjust via this instruction, is also gone.

So, Reeza's answer is exactly what I was looking for.

Indeed, "it was blank", so I created an "autoexec.sas" with the txt.-editor and stored it in my "current folder" and it worked perfectly.

To combine, I take the solution by Bruno and create a file with all librefs-statements. This is taken aside, as recommended by Reeza.

The content of that very file is pasted into - the now existing - "autoexec.sas"  in my "current folder".

Such, if it happens again (which, as I hope, should not, for I know have an autoexec.sas, but, who knows), I have a back up.

 

So, once again, thank you very much indeed.

It is always a horror to see all the libraries vanished.

 

Sinistrum

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 419 views
  • 4 likes
  • 3 in conversation