Chapter Contents

Previous

Next
SAS Component Language: Reference

Assigning Filerefs

To establish the communication between SAS software and an external file, you must assign a fileref to the file with the FILENAME function. If an application requires that users specify the name of the physical file, then create a block of SCL code labeled with a window variable name to run only when a user enters a filename in that field. You can also put the FILENAME function in the MAIN section so that it executes after a user specifies the filename. In this case, add a statement to check that the field containing the filename has been modified so that the FILENAME function does not run every time the MAIN section runs. When a program can specify the name of the physical file without user input, put the function in the initialization section so that the function executes only once, before the window opens.

You can also assign filerefs outside of an application when files are used by all or large parts of your application. You assign filerefs to these files by using the FILENAME statement in base SAS in the application's start-up file (the autoexec file). For more information about assigning filerefs, see the SAS documentation for your operating environment.

There are other SCL functions that you can use to manipulate filerefs. Use these functions to prevent programs from terminating prematurely because of possible errors (for example, a fileref is already assigned or a physical file does not exist).


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.