File Shortcuts

Reply
N/A
Posts: 0

File Shortcuts

Hi,
could you tell me how can I copy all my shortcuts from "File Shortcuts" to another SAS Profile ?

Regards...
N/A
Posts: 0

Re: File Shortcuts

I don't have another profile to play with, so I'll give you some pieces of the answer so you can put it together yourself. But first of all, a warning. Some of these file references are defined from within the SAS configuration, and you are in danger of losing some functionality with your SAS macro path and your messaging. So, take each step slowly, and restart your SAS session to restore the defaults.

The file shortcuts you create are file references defined to SAS, and are visible through a SAS dictionary table and a SAS view. This means you cannot add them directly to any database, but rather assign them the way SAS expects them to be assigned, with a SAS FILENAME or similar statement. This approach is going to involve building SAS statements from a data set and requires care in the construction of the syntax.

My preference would be to find the correct file references and store them in a SAS program that could then be run by each person who needed the assignments. For a clinical trial, this would be much safer, and I suggest you aim for this as your end goal, and use this solution as a stepping stone to getting a program with all the file references.

File references can be listed from a View maintained by SAS. This piece of code will show you what is assigned.

Proc Print Data = SASHELP.VEXTFL;
Run;

You can save these by storing them in a permanent data set with code like this.

[Pre] Data SASUSER.MYFILES;
Set SASHELP.VEXTFL;
Run;
[/Pre]

You can then make those available to another SAS session, get a table of its assignments and compare the two to get those that were assigned to your master session that do not appear in your child session. Note that the code from here on is untested, since I don't have the means to simulate your environment.

[Pre] Proc Sql _Method STimer;

Create Table UNASSIGNED As
Select *
From SASUSER.MYFILES
Where XPATH
Not In( Select XPATH
From SASHELP.VEXTFL);

Quit;
[/Pre]

I have looked for the path assignment because the file references may change between SAS session invocations due to the sequence in which the assignments are made. The session also has concatenated assignments where a single reference such as SASAUTOS has a number of physical file paths to be searched.

Look at the references that start with "#LN". These are all defined to the session by SAS and should not be messed with. Most of these are assigned from the SAS config file, and matching the config files is the better solution to aligning these assignments. For instance, if you don't assign #LN00001 correctly, you will have SAS complaining it cannot provide messages for SAS errors and Warnings.

With the remaining assignments, you could use Call Execute() to assign the references directly, or you could save the results to a file and then call the file to make the assignments. We will take this path, because it leads to a longer term solution where you maintain a program of required file references in a single place for all users, and don't go through this process again.

First, sort the data because we will use BY Processing to allow concatenated file references. Then submit the following code, but note that the first time the "File" assignment in the data step is commented out so that we can look at the syntax in the log and verify it is correct.

[Pre] Proc Sort Data = UNASSIGNED;
By FILEREF;
Run;

FileName SASFILES "C:\Saswork\Filerefs.Sas";

Data _NULL_;
* File SASFILES;
Set UNASSIGNED;
By FILEREF;
If First.FILEREF Then Do;
Put "Filename " FILEREF;
If Not Last.FILEREF Then Put "( ";
End;
Put '"' XPATH '"';
If Last.FILEREF Then Do;
If Not First.FILEREF Then Put ")";
Put ";";
End;
Run;
[/Pre]

When you are satisfied with that, uncomment the "File" statement and create the include file.

Note that the ENGINE setting has not been used, and if you have references using engine settings then you should look at the way in which that is assigned to the master session and copy that code over.

Note too that the physical file paths need to be valid for all SAS sessions running the code, and if files are available on local drives, or in user directories, then these will not copy correctly using this method.

Once again, be aware that this is a "patch" solution and should not be used routinely. There is a danger that you will have an unstable SAS session if you reassign file references that should not be changed, such as the system or SASAUTOS assignments, and the better solution is to document the correct paths for all team members and then create and debug an inclusion file for these assignments.

Kind regards

David
N/A
Posts: 0

Re: File Shortcuts

Kosa

I hope this is not too late to be helpful.

If your file shortcuts are built in SAS through the SAS Explorer ("New File Shortcut" dialog), using the "Enable at Startup" checkbox, then these can be extracted as text and transferred to, and imported into the new environment. The following code extracts file shortcuts that have "Enable at Startup" set [pre]proc registry export="my_reg&sysdate..txt" startat='CORE\OPTIONS\FILEREFS'; run; [/pre]
If you would like to look at the export, then run :[pre] proc fslist file="my_reg&sysdate..txt"; run; [/pre]
Once that text file is delivered to the "current folder" of the destination environment, the shortcuts can be loaded with an even simpler statement:[pre]
proc registry export="my_reg.txt"; run; [/pre] (just fill in the relevant date at ~ ~ ~ ~ )

If you use the "Favorite Folders" area of the SAS Explorer, these are stored at 'CORE\EXPLORER\FOLDERS'. Libraries defined with "Enable at Startup" are stored at 'CORE\OPTIONS\LIBNAMES'

enjoy

Good Luck

PeterC
Frequent Contributor
Posts: 91

Re: File Shortcuts

Did you mean?
proc registry import="my_reg.txt"; run;
(just fill in the relevant date at ~ ~ ~ ~ )
N/A
Posts: 0

Re: File Shortcuts

pardon me !

yes of course

read with import=

not export=

Peter
Post a Question
Discussion Stats
  • 4 replies
  • 419 views
  • 0 likes
  • 2 in conversation