Chapter Contents


SAS/AF Software: Class Dictionary

Using the SAS File List Model

The SAS File List model is both a parent of other models (such as the Catalog List Model and the Data Set List Model) and a model that you can use for retrieving SAS files. Where the subclasses of SAS File List Model limit the type of files you can select (via the typeFilter attribute), a SAS file list model can access all SAS file types, including MDDB, ACCESS, Views, etc.

You can use the SAS File List Model class in conjunction with a viewer control for model/view communication. When you drop a model on a control in a frame, or you set the control's model attribute to the name of the instantiated model object, the items attribute of the view is automatically set to the items attribute of the model when you specify the library attribute on the model.

For example, add a list box control and a SAS file list model to a frame, then set listbox1.model to sasfilelist1. To display a list of SAS files in the listbox, specify a value for sasfilelist1.library.

You can also use the SAS file list model in an SCL program to retrieve a list of SAS files from a specified library. Once you specify a valid SAS library for the object's library attribute, simply query the items attribute to get the list of catalog entries. To further qualify the selection, specify other attribute values (such as typeFilter or levelCount) for the object before you query items.

For example, the following code instantiates a SAS file list model and returns a list of all MDDBs in the library sasuser:

  dcl sashelp.classes.sasfilelist_c.class sasobj; 
  dcl list sasfiles; 
  dcl num rc;
  sasfiles = makelist(); 
  sasobj = _new_ sashelp.classes.sasfilelist_c();
  sasobj.library = 'sasuser'; 
  sasobj.typeFilter = 'MDDB';
  sasfiles = sasobj.items; 
  call putlist(sasfiles); 
  rc = dellist(sasfiles); 

Working with SAS File Names

The SAS File List Model items attribute is populated by a list of SAS files. Each list item is assigned a unique name that is equal to libname.sasfile. The unique name appears in the viewer to which you assign the model as long as the model's SASFileDisplayed attribute is set to Yes.

If SASFileDisplayed is set to No, the name will not appear in the items attribute list, which means it will not display in any associated view. Each item on the list, however, is a named item that also corresponds to the SAS file name. You can query the items attribute list using the NAMEITEM function to determine each SAS file's unique name.

  1. Create a frame with a listbox, sasfilelist model, and a text label.

  2. Add the following SCL code:

  textlabel1.label=nameitem(Sasfilelist1.items, Listbox1.selectedIndex);

Chapter Contents



Top of Page

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